#include<iostream> #include<cmath> using namespace std; //利用数组下标作为多项式x的次方 int caculate(int arr[],int x,int n) { int sum = 0; for(int i = 0;i <= n;i++) sum += (arr[i] * pow(x, i)); return sum; } int main(void) { int m; cin >> m; int arr[11]; while(m--) { int n; cin >> n; for(int i = 0;i <= n;i++) { int value; cin >> value; arr[i] = value; } int x; cin >> x; cout << caculate(arr, x, n) << endl; } return 0; }