Josif_tepe

Untitled

Mar 9th, 2026
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n, x;
  8.     cin >> n >> x;
  9.    
  10.     for(int i = 1; i <= n; i++) {
  11.         if(i % 2 == 1) {
  12.             x += 2;
  13.         }
  14.         else {
  15.             x--;
  16.         }
  17.        
  18.         if(x % 4 == 0) {
  19.             x = -x;
  20.         }
  21.     }
  22.    
  23.     cout << x << endl;
  24.     return 0;
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment