Guest User

Untitled

a guest
Dec 15th, 2019
83
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int s[65537];
  7.  
  8. int main() {
  9. int n;
  10. cin >> n;
  11. int arr[n];
  12. s[0] = 0;
  13. int cnt = 0;
  14. for (int i = 0; i < n; i++) {
  15. cin >> arr[i];
  16. }
  17. int up = 0;
  18. for (int i = 1; i < (1 << n); i++) {
  19. if (i == 1 << (up + 1))
  20. up++;
  21. s[i] = s[i ^ (1 << up)] + arr[up];
  22.  
  23. }
  24. for (int A = 1; A < (1 << n); A++) {
  25. for (int B = (((1 << n) - 1) & n); B > 0; B--) {
  26. if ((A & B) == B)
  27. cnt += s[A] % s[B];
  28. }
  29. }
  30. cout << cnt;
  31.  
  32. return 0;
  33. }
RAW Paste Data