Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int N;
- cin >> N;
- vector < int > values(1 << N);
- for(int& x : values)
- cin >> x;
- vector < int > sum(1 << N);
- for(int i = 0; i < (1 << N); ++i)
- sum[i] = values[i];
- for(int k = 0; k < N; ++k)
- for(int s = 0; s < (1 << N); ++s)
- if(s & (1 << k))
- sum[s] += sum[s ^ (1 << k)];
- cout << sum[(1 << N) - 1];
- }
Advertisement
Add Comment
Please, Sign In to add comment