#include <iostream>
#include <vector>
#include <string>
#include <sstream>
using namespace std;
string s;
vector<int> a,x;
long long int poly(int y){
long long int ans=a[0];
for(int i=1;i<a.size();i++){
ans=ans*y+a[i];
}
return ans;
}
int conv(vector<int> &b){
stringstream ss(s);
int y;
while(ss>>y){
b.push_back(y);
}
}
int main(){
ios::sync_with_stdio(0);
while(ws(cin)&&!cin.eof()){
getline(cin,s);
a.clear();
conv(a);
getline(cin,s);
x.clear();
conv(x);
cout<<poly(x[0]);
for(int i=1;i<x.size();i++)
cout<<' '<<poly(x[i]);
cout<<endl;
}
}
#include <vector>
#include <string>
#include <sstream>
using namespace std;
string s;
vector<int> a,x;
long long int poly(int y){
long long int ans=a[0];
for(int i=1;i<a.size();i++){
ans=ans*y+a[i];
}
return ans;
}
int conv(vector<int> &b){
stringstream ss(s);
int y;
while(ss>>y){
b.push_back(y);
}
}
int main(){
ios::sync_with_stdio(0);
while(ws(cin)&&!cin.eof()){
getline(cin,s);
a.clear();
conv(a);
getline(cin,s);
x.clear();
conv(x);
cout<<poly(x[0]);
for(int i=1;i<x.size();i++)
cout<<' '<<poly(x[i]);
cout<<endl;
}
}
Comments
Post a Comment