Created
April 12, 2017 16:16
-
-
Save henrybear327/a4c5b6131e32c0aded1fd4bda91ca7e4 to your computer and use it in GitHub Desktop.
ITSA 2017 Apr 5.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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