1280: Polly the Polynomial

1280: Polly the Polynomial


ResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE
3s8192K452148Standard

Algebra! Remember algebra? There is a theory that as engineers progresses further and further in their studies, they lose basic math skills. This problem is designed to help you remember those basic algebra skills, make the world a better place, etc., etc.

Input

Your program should accept an even number of lines of text. Each pair of lines will represent one problem. The first line will contain a list of integers { } which represent a set of coefficients to a polynomial expression. The order of the polynomial is n. The coefficients should be paired with the terms of the polynomial in the following manner:

 

The second line of text represents a sequence of values for x, { }.

Output

For each pair of lines, your program should evaluate the polynomial for all the values of x ( through ) and output the resulting values on a single line.

Sample Input

 

-2
5 0 1 6
1 -1
7 6 -1

Sample Output

 

-2 -2 -2 -2
6 5 -2

 

 


This problem is used for contest: 107 

 

#include<iostream>
#include<string>
#include<sstream>
#include<vector>
using namespace std;
int main()
{
    string str;
    while(getline(cin,str))
    {
        istringstream sin(str);
        vector< int > a;
        int n;
        while(sin>>n) a.push_back(n);
        //for(int i=0;i<a.size();i++) printf("%d...",a[i]);printf("/n");
        str.clear();
        getline(cin,str);
       // cout<<str<<"........"<<endl;
        istringstream fin(str);
        int flag=0;
        while(fin>>n)
        {
           //printf("%d...../n",n);
           if(flag==0) flag=1;else printf(" ");
            int sum=0;
            for(int i=0;i<a.size();i++) sum=sum*n+a[i];
            printf("%d",sum);
        }
        printf("/n");
    }
    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值