其他分享
首页 > 其他分享> > 1223:An Easy Problem

1223:An Easy Problem

作者:互联网

An Easy Problem

 1 #include<iostream>
 2 using namespace std;
 3 
 4 int cnt(int n){
 5     int sum=0;
 6     while(n){
 7         if(n%2)sum++;
 8         n/=2;
 9     }
10     return sum;
11 }
12 int main(){
13     int n;
14     while(cin>>n){
15         if(!n)break;
16         for(int i=n+1;;i++){
17             if(cnt(i)==cnt(n)){
18                 cout<<i<<endl;
19                 break;
20             }
21         }
22     }
23     return 0;
24 }

 

标签:cnt,1223,int,sum,++,Easy,Problem
来源: https://www.cnblogs.com/sxrekord/p/an_easy_problem.html