Uva--10719 (数学)
2014-06-10 00:28:06
题意&思路:简单的多项式除法模拟,写的略丑。。
#include <cstdio> #include <iostream> using namespace std; int main(){ int k,t,r,q[10005],cnt; char c; while(scanf("%d",&k) == 1){ getchar(); cnt = 0; r = 0; while(scanf("%d",&t) == 1){ c = getchar(); t -= r; q[cnt++] = t; if(c == '\n') break; r = (-k) * t; } printf("q(x):"); for(int i = 0; i < cnt - 1; ++i) printf(" %d",q[i]); puts(""); printf("r = %d\n\n",q[cnt - 1]); } return 0; }