-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathC_Reverse_XOR.cpp
More file actions
52 lines (42 loc) · 1.13 KB
/
C_Reverse_XOR.cpp
File metadata and controls
52 lines (42 loc) · 1.13 KB
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
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;cin>>t;
while(t--){
int n;cin>>n;
//cout<<(n^0)<<endl;
string sn;
if (n == 0) sn = "0";
else {
while (n > 0) {
sn.push_back((n & 1) ? '1' : '0');
n >>= 1;
}
reverse(sn.begin(), sn.end());
}
string ans="NO";
for (int len = 1; len < 64; len++) {
if ((int)sn.size() <= len) {
string w(len - sn.size(), '0');
w += sn;
bool ok = true;
for (int i = 0; i < len/2; i++) {
if (w[i] != w[len - 1 - i]) {
ok = false;
break;
}
}
if (ok && (len % 2 == 1)) {
if (w[len/2] != '0') ok = false;
}
if (ok) {
ans = "YES";
break;
}
}
}
cout << ans << "\n";
}
return 0;
}