1280: Polly the Polynomial
2010-07-10 20:27
274 查看
1280: Polly the Polynomial
Algebra! Remember algebra? There is a theory that as engineers progresses further and further in their studies, they lose basic math skills. This problem is designed to help you remember those basic algebra skills, make the world a better place, etc., etc.
} which represent a set of coefficients to a polynomial expression. The order of the polynomial is n. The coefficients should be paired with the terms of the polynomial in the following manner:
The second line of text represents a sequence of values for x, {
}.
through
) and output the resulting values on a single line.
This problem is used for contest: 107
#include<iostream>
#include<string>
#include<sstream>
#include<vector>
using namespace std;
int main()
{
string str;
while(getline(cin,str))
{
istringstream sin(str);
vector< int > a;
int n;
while(sin>>n) a.push_back(n);
//for(int i=0;i<a.size();i++) printf("%d...",a[i]);printf("/n");
str.clear();
getline(cin,str);
// cout<<str<<"........"<<endl;
istringstream fin(str);
int flag=0;
while(fin>>n)
{
//printf("%d...../n",n);
if(flag==0) flag=1;else printf(" ");
int sum=0;
for(int i=0;i<a.size();i++) sum=sum*n+a[i];
printf("%d",sum);
}
printf("/n");
}
return 0;
}
Result | TIME Limit | MEMORY Limit | Run Times | AC Times | JUDGE |
---|---|---|---|---|---|
3s | 8192K | 452 | 148 | Standard |
Input
Your program should accept an even number of lines of text. Each pair of lines will represent one problem. The first line will contain a list of integers {} which represent a set of coefficients to a polynomial expression. The order of the polynomial is n. The coefficients should be paired with the terms of the polynomial in the following manner:
The second line of text represents a sequence of values for x, {
}.
Output
For each pair of lines, your program should evaluate the polynomial for all the values of x (through
) and output the resulting values on a single line.
Sample Input
-2 5 0 1 6 1 -1 7 6 -1
Sample Output
-2 -2 -2 -2 6 5 -2
This problem is used for contest: 107
#include<iostream>
#include<string>
#include<sstream>
#include<vector>
using namespace std;
int main()
{
string str;
while(getline(cin,str))
{
istringstream sin(str);
vector< int > a;
int n;
while(sin>>n) a.push_back(n);
//for(int i=0;i<a.size();i++) printf("%d...",a[i]);printf("/n");
str.clear();
getline(cin,str);
// cout<<str<<"........"<<endl;
istringstream fin(str);
int flag=0;
while(fin>>n)
{
//printf("%d...../n",n);
if(flag==0) flag=1;else printf(" ");
int sum=0;
for(int i=0;i<a.size();i++) sum=sum*n+a[i];
printf("%d",sum);
}
printf("/n");
}
return 0;
}
相关文章推荐
- 1280: Polly the Polynomial
- UVa 498 - Polly the Polynomial
- UVa 498 - Polly the Polynomial
- uva 498 - Polly the Polynomial
- heru 1280 Turn the corner(08哈尔滨网赛 三分)
- Numeric test, find the solution of non-polynomial equation, play
- 3.1 The Interpolating Polynomial(站点)
- #1280 : Rikka with Sequence II [meet int the middle]
- UVa10326 - The Polynomial Equation
- 3.1 The Interpolating Polynomial(网站)
- Introduction to Android Theme Customization
- Sempr == The Best Problem Solver? 1898
- the file “XXX” could not be opened because you don't have permission to view it
- I’ve seen the world,lit it up as my stage now
- process the options for command
- The database returned no natively generated identity value
- The following error occured:These Qt version are inaccessible: qt in **
- An Interactive Guide To The Fourier Transform
- [Memory] A look at the x86 "Self-referencing Page Directory trick"
- Failed to load JavaHL Library. These are the errors that were encountered: no libsvnjavahl-1 in java