1 solutions
-
0
C++ :
#include<bits/stdc++.h> using namespace std; int n,x,a[32],t; bool f(int x) { fill(a,a+31,0); t=0; for(int i=x;i>0;i/=2) a[t++]=i%2; for(int i=0;i<t-1;i++) if(a[i]==a[i+1]) return 0; return 1; } int main() { cin>>n; while(n--) { cin>>x; if(f(x)) cout<<"true"<<" "; else cout<<"false"<<" "; } return 0; }
- 1
Information
- ID
- 932
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By