3 solutions
- 1
Information
- ID
- 1141
- Time
- 1000ms
- Memory
- 1MiB
- Difficulty
- 7
- Tags
- # Submissions
- 158
- Accepted
- 31
- Uploaded By
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
while(cin>>n){
int cnt=0;
int c=0,k=1;
while(cnt<n){
cnt=(k<<c);//1*(2^c)快速计算冥
c++;
}
if(cnt==n)cout<<"yes"<<'\n';
else cout<<"no"<<'\n';
}
//位运算非正统写法
return 0;
}
# include<bits/stdc++.h>
using namespace std;
void in(int i){
int x=true;
while(i>1){
if(i%2==1){
x=false;
break;
}
i/=2;
}
if(x)cout<<"yes\n";
else cout<<"no\n";
}
int main(){
int x;
while(cin>>x)in(x);
return 0;
}
By signing up a ZXOJ universal account, you can submit code and join discussions in all online judging services provided by us.