Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- typedef pair<ll, ll> pll;
- typedef pair<int, int> pii;
- #define endl "\n"
- const ll INF = 1e15;
- const int MOD = 1e9 + 7;
- const double EPS = 1e-9;
- const double PI = acos(-1.0);
- mt19937 rng((int)chrono::steady_clock::now().time_since_epoch().count());
- vector<ll> read(const string& s) {
- vector<ll> ret;
- ll cur;
- stringstream ss(s);
- while (ss >> cur)
- ret.push_back(cur);
- return ret;
- }
- int main() {
- ios::sync_with_stdio(false);
- cin.tie(NULL), cout.tie(NULL);
- string s;
- while (getline(cin, s)) {
- vector<ll> c = read(s);
- reverse(c.begin(), c.end());
- getline(cin, s);
- vector<ll> x = read(s);
- ll sum = 0;
- for (auto w : c)
- sum += w;
- int n = (int) x.size();
- for (int i = 0; i < n; ++i) {
- ll cur_x = x[i];
- if (cur_x == 1)
- cout << sum << " \n"[i == n - 1];
- else {
- ll ans = 0, p = 1;
- for (auto w : c) {
- ans += w * p;
- p *= cur_x;
- }
- cout << ans << " \n"[i == n - 1];
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement