-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFinding OR Sum.cpp
More file actions
55 lines (51 loc) · 992 Bytes
/
Finding OR Sum.cpp
File metadata and controls
55 lines (51 loc) · 992 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//source from tourist
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int tt;
cin >> tt;
while (tt--) {
vector<int> val(30, 0);
for (int rot = 0; rot < 2; rot++) {
int n = 0;
for (int i = 0; i < 30; i++) {
if (i % 2 == rot) {
n += 1 << i;
}
}
cout << n << endl;
int got;
cin >> got;
for (int i = 0; i < 30; i++) {
if (i % 2 == rot) {
got -= 1 << (i + 1);
}
}
for (int i = 0; i < 30; i++) {
if (i % 2 != rot) {
val[i] = (got >> i) & 3;
}
}
}
cout << "!" << endl;
int m;
cin >> m;
int res = 0;
for (int i = 0; i < 30; i++) {
if (m & (1 << i)) {
res += 1 << (i + 1);
} else {
res += val[i] << i;
}
}
cout << res << endl;
}
return 0;
}