|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#include <iostream>
#include <cmath>
#include <iomanip>
#include <sstream>
using namespace std;
int main()
{
double x,ncoef=0,coef,result=0,deg=0;
string str;
stringstream sstream;
cin >> x;
while(1)
{
cin >> str;
if(cin.eof())
{
break;
}
sstream << str << " ";
ncoef++;
}
for(int i = ncoef; i > 0; i--)
{
sstream >> coef;
result += coef*pow(x,i-1);
}
cout << setprecision(4) << fixed << result << endl;
return 0;
}
|