UVA 10719

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int k;
    int a[10010];
    int b[10010]={0};
    while(cin>>k)
    {
        int flag=0,j,r,temp;
        char c;
        while(scanf("%d%c",&temp,&c)==2)
        {
            a[flag++]=temp;
            if(c=='\n')break;
        }
        b[1]=a[0];
        for(j=2;j<flag;j++)
            b[j]=k*b[j-1]+a[j-1];
        r=a[flag-1]+k*b[flag-1];
        cout<<"q(x): ";
        for(j=1;j<flag;j++)
            cout<<b[j]<<" ";
        cout<<endl;
        cout<<"r = "<<r<<endl;
        cout<<endl;
    }
    return 0;
}

 

posted @ 2012-04-28 12:10  open your eyes  阅读(130)  评论(0编辑  收藏  举报