題目:
https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=14&page=show_problem&problem=1209
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| #include <iostream> #include <vector> #include <string> #include <sstream>
#define ll long long
using namespace std;
int main(){ string line; while(getline(cin, line)){ stringstream ss1(line); int x; ss1 >> x;
getline(cin, line); stringstream ss2(line); vector<ll> c; ll a; while(ss2 >> a) c.push_back(a);
int n = c.size() - 1; ll result = 0; for(int i=0; i < n; ++i){ result = result * x + c[i] * (n-i); } cout << result << '\n'; } return 0; }
|