Josif_tepe

Untitled

Mar 10th, 2026
125
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 <set>
  4. #include <cstring>
  5. #include <deque>
  6. using namespace std;
  7. typedef long long ll;
  8.  
  9. ll solve(ll x, ll days) {
  10.     for(ll i = 1; i <= days; i++) {
  11. //        cout << x << " ";
  12.         if(i % 2 == 1) {
  13.             x += 2;
  14.         }
  15.         else {
  16.             x--;
  17.         }
  18.        
  19.         if(x % 4 == 0) {
  20.             x = -x;
  21.         }
  22.        
  23.     }
  24.     return x;
  25. }
  26. int main()
  27. {
  28.     ll n, x;
  29.     cin >> n >> x;
  30.    
  31.     ll F = n / 8, rem = n % 8;
  32.    
  33.     ll a = solve(x, 8);
  34.     ll d = solve(a, rem) - solve(x, rem);
  35.    
  36.     cout << solve(x, rem) + F * d << endl;
  37.    
  38.    
  39.    
  40.     return 0;
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment