Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. int main() {
  8. int n;
  9. cin >> n;
  10. int arr[n];
  11. int sum = 0;
  12. int s_a[65537];
  13. s_a[0] = 0;
  14. int s_b[65537];
  15. s_b[0] = 0;
  16. int cnt = 0;
  17. for (int i = 0; i < n; i++) {
  18. cin >> arr[i];
  19. sum += arr[i];
  20. }
  21. int up = 0;
  22. for (int A = 1; A < (1 << n) ; A ++) {
  23. if (A == pow(2, up + 1))
  24. up++;
  25. s_a[A] = s_a[A ^ (1 << up)] + arr[up];
  26. int t = 0;
  27. for (int B = 1; B < (1 << n) ; A ++) {
  28. if (B == pow(2, t + 1))
  29. t++;
  30. s_b[B] = s_b[B ^ (1 << t)] + arr[t];
  31. if (s_b[B] == s_a[A]) {
  32. continue;
  33. } else {
  34. cnt += s_a[A] % s_b[B];
  35. }
  36. }
  37. }
  38. cout << cnt;
  39.  
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement