uva10719 Quotient Polynomial
这道题目呢就是属于一个多项式的展开题目,没什么难处,不需要算法,只需要把所给的多项式与给出的常数k一一乘开然后列出新的多项式系数就行
View Code
#include<stdio.h> #include<string.h> int main() { char ch; int i, k, p[10010], q[10010]={0}, j; while(scanf("%d",&k) != EOF) { i = 0; while(1) { scanf("%d",&p[i++]); ch = getchar(); if(ch == '\n') break; } q[0] = p[0]; printf("q(x): %d",q[0]); for(j = 1;j < i-1; j++) { q[j] = q[j-1]*k + p[j]; printf(" %d",q[j]); } printf("\nr = %d\n\n",q[i-2]*k+p[i-1]); } return 0; }