-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1607B.cpp
More file actions
35 lines (28 loc) · 716 Bytes
/
1607B.cpp
File metadata and controls
35 lines (28 loc) · 716 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
#include <bits/stdc++.h>
using namespace std;
#define fast_io ios::sync_with_stdio(false); cin.tie(nullptr);
int main() {
fast_io;
int t;
cin >> t;
while (t--) {
// solve here
long long start, jumps;
cin >> start >> jumps;
long long final_pos;
if (jumps % 4 == 1)
final_pos = -jumps;
else if (jumps % 4 == 2)
final_pos = 1;
else if (jumps % 4 == 3)
final_pos = jumps + 1;
else
final_pos = 0;
if (start % 2 == 0)
final_pos = start + final_pos;
else
final_pos = start - final_pos;
cout << final_pos << endl;
}
return 0;
}