Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <set>
- using namespace std;
- typedef long long ll;
- ll solve(ll x, ll days) {
- for(ll i = 1; i <= days; i++) {
- if(i % 2 == 1) {
- x += 2;
- }
- else {
- x--;
- }
- if(x % 4 == 0) {
- x = -x;
- }
- }
- return x;
- }
- int main() {
- ios_base::sync_with_stdio(false);
- ll n, x;
- cin >> n >> x;
- ll F = n / 8;
- ll rem = n % 8;
- ll a = solve(x, 8);
- ll d = solve(a, rem) - solve(x, rem);
- cout << solve(x, rem) + F * d << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment