Skip to content

Instantly share code, notes, and snippets.

@henrybear327
Created April 12, 2017 16:16
Show Gist options
  • Save henrybear327/a4c5b6131e32c0aded1fd4bda91ca7e4 to your computer and use it in GitHub Desktop.
Save henrybear327/a4c5b6131e32c0aded1fd4bda91ca7e4 to your computer and use it in GitHub Desktop.
ITSA 2017 Apr 5.cpp
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
int ncase;
scanf("%d", &ncase);
while(ncase--) {
int n;
scanf("%d", &n);
ll inp[n];
for(int i = 0; i < n; i++) {
scanf("%lld", &inp[i]);
}
int cnt[n];
ll base = 1LL;
for(int i = n - 1; i >= 0; i--) {
cnt[i] = base;
base <<= 1;
}
ll ans = 0;
for(int i = 0; i < n; i++) {
ans += cnt[i] * inp[i];
}
printf("%lld\n", ans);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment