-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheqbyxor.cpp
More file actions
42 lines (42 loc) · 889 Bytes
/
eqbyxor.cpp
File metadata and controls
42 lines (42 loc) · 889 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
#include <bits/stdc++.h>
#define ll long long
using namespace std;
bool isEqualRing(int n)
{
return (ceil(log2(n)) == floor(log2(n)));
}
unsigned countRing(unsigned int z)
{
return (int)log2(z) + 1;
}
int main()
{
// your code goes here
int post;
cin >> post;
while (post--)
{
ll num1, num2, num, flag, r, R;
cin >> num1 >> num2 >> num;
flag = num1 ^ num2;
if (num1 == num2)
cout << 0 << "\n";
else if (flag < num)
cout << 1 << "\n";
else
{
r = countRing(flag);
R = countRing(num);
if (r == R)
{
if (isEqualRing(num))
cout << -1 << "\n";
else
cout << 2 << "\n";
}
else
cout << -1 << "\n";
}
}
return 0;
}