标签:blog io os ar for sp 2014 log amp
题目:一直多项式的系数,求不同的x对应多项式的值。
分析:数学题,简单题。直接代入多项式计算即可。
说明:注意输入格式。
#include <iostream> #include <cstdlib> #include <cstring> #include <cstdio> using namespace std; int temp,c[10000]; int main() { int n; while ((temp = getchar()) != EOF) { int count = 0; while (temp != '\n') { if (temp == '-' || temp >= '0' && temp <= '9') { ungetc(temp, stdin); scanf("%d",&c[count ++]); } temp = getchar(); } int flag = 0,data,sum; temp = getchar(); while (temp != '\n') { if (temp == '-' || temp >= '0' && temp <= '9') { ungetc(temp, stdin); scanf("%d",&data); sum = 0; for (int i = 0 ; i < count ; ++ i) { sum *= data; sum += c[i]; } if (flag) printf(" "); printf("%d",sum); flag = 1; } temp = getchar(); } printf("\n"); } return 0; }
UVa 498 - Polly the Polynomial
标签:blog io os ar for sp 2014 log amp
原文地址:http://blog.csdn.net/mobius_strip/article/details/40589465