-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1607B.cpp
More file actions
36 lines (29 loc) · 802 Bytes
/
Copy path1607B.cpp
File metadata and controls
36 lines (29 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Created on 09-Sep-25
//done
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL)
#define getUnique(v) {sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());}
#define nl '\n'
int main() {
faster;
int t;
cin >> t;
while (t--) {
ll xi, n;
cin >> xi >> n;
//if the first jump is positive, then it is sequence like 1 - 2 - 3 + 4 + 5
//every 4 numbers add to 0
ll start = (n / 4) * 4; // nearest multiple of 4
for (ll i = start + 1; i <= n; i++) {
if (xi % 2 != 0) {
xi += i;
} else xi -= i;
}
cout << xi << endl;
}
return 0;
}