Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- int arr[n];
- int sum = 0;
- int s_a[65537];
- s_a[0] = 0;
- int s_b[65537];
- s_b[0] = 0;
- int cnt = 0;
- for (int i = 0; i < n; i++) {
- cin >> arr[i];
- sum += arr[i];
- }
- int up = 0;
- for (int A = 1; A < (1 << n) ; A ++) {
- if (A == pow(2, up + 1))
- up++;
- s_a[A] = s_a[A ^ (1 << up)] + arr[up];
- int t = 0;
- for (int B = 1; B < (1 << n) ; A ++) {
- if (B == pow(2, t + 1))
- t++;
- s_b[B] = s_b[B ^ (1 << t)] + arr[t];
- if (s_b[B] == s_a[A]) {
- continue;
- } else {
- cnt += s_a[A] % s_b[B];
- }
- }
- }
- cout << cnt;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement