Advertisement
Josif_tepe

Untitled

Mar 7th, 2024
534
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <map>
  5. #include <algorithm>
  6. using namespace std;
  7. typedef long long ll;
  8.    
  9. int main()
  10. {
  11.     int n;
  12.     cin >> n;
  13.    
  14.     ll add = 0, subtract = 0;
  15.     for(int i = 1; i <= n; i++) {
  16.         int x;
  17.         cin >> x;
  18.         int rounds = n;
  19.         while(rounds > 1) {
  20.             if(i <= rounds / 2) {
  21.                 add += x;
  22.             }
  23.             else if(i > rounds / 2 and i <= rounds) {
  24.                 subtract += x;
  25.             }
  26.            
  27.             rounds /= 2;
  28.         }
  29.     }
  30.     cout << add - subtract << endl;
  31.    
  32.  
  33.     return 0;
  34. }
  35. // 2222222222
  36. // 22222222222
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement