-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEqual_by_XORing.cpp
More file actions
46 lines (45 loc) · 935 Bytes
/
Copy pathEqual_by_XORing.cpp
File metadata and controls
46 lines (45 loc) · 935 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
#include <bits/stdc++.h>
#define ll long long
#define fr(i, a, b) for (int i = a; i < b; i++)
using namespace std;
int main()
{
int q;
cin >> q;
while (q--)
{
int a, b, c;
cin >> a >> b >> c;
if (a == b)
{
cout << 0 << endl;
}
else
{
int x = a ^ b;
if (x < c)
{
cout << 1 << endl;
}
else
{
if (log(x) == log(c))
{
if (ceil(log2(c)) == floor(log2(c)))
{
cout << -1<< endl;
}
else
{
cout << 2 << endl;
}
}
else
{
cout << -1 << endl;
}
}
}
}
return 0;
}