-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReverseXOR.cpp
More file actions
55 lines (55 loc) · 1.19 KB
/
ReverseXOR.cpp
File metadata and controls
55 lines (55 loc) · 1.19 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
53
54
55
#include<bits/stdc++.h>
using namespace std;
int t;
long long n;
void process(){
if(!n){
cout<<"YES\n";
return;
}
string s="";
for(int i=0;i<40;i++)s.push_back('0');
int st=-1;
for(long long i=30;i>=0;i--){
if(((n>>i)&1)){
s.push_back('1');
if(st==-1)st=s.size()-1;
}
else s.push_back('0');
}
for(int i=0;i<=st;i++){
string tmp="";
for(int j=i;j<s.size();j++)tmp.push_back(s[j]);
string tmp1=tmp;
reverse(tmp1.begin(),tmp1.end());
if(tmp==tmp1){
bool ok=1;
if((int(tmp.size()))&1){
if(tmp[(tmp.size()+1)/2-1]=='1')ok=0;
}
if(ok){
cout<<"YES\n";
return;}
}
}
cout<<"NO\n";
}
void init(){
cin>>t;
while(t--){
cin>>n;
process();
}
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
#define NAME "nazunasdish"
if(fopen(NAME".inp","r")){
freopen(NAME".inp","r",stdin);
freopen(NAME".out","w",stdout);
}
// clock_t beg=clock();
init();
// process();
// cerr<<double(clock()-beg)/CLOCKS_PER_SEC;
}