文章
84
粉丝
408
获赞
33
访问
877.1k
#include<iostream>
#include<vector>
using namespace std;
class poly{
private:
vector<int> vint;
int x;
int N;
int ans;
public:
poly(){}
~poly(){}
void in();
int out(int i);
};
void poly::in()
{
int num;
cin >> N;
for (int i = 0; i <= N; i++) {
cin >> num;
vint.push_back(num);
}
cin >> num;
x = num;
ans = 1;
}
int poly::out(int i)
{
if (i == 0)
return ans*vint[i] + out(i+1);
else if (i == N) {
ans *= x;
return ans*vint[i];
}
else {
ans *= x;
return ans*vint[i] + out(i+1);
}
}
int main()
{
int m;
cin >> m;
while (m--) {
poly p;
p.in();
cout << p.out(0) << endl;
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发