Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main(){
- int t, counter1, counter2;
- cin>>t;
- int n;
- for(int i=1; i<=t; i++){
- counter1=0;
- cin>>n;
- for(int j=1; j<=32; j++){
- if (n & (1 << (j - 1)))
- counter1++;
- }
- while(1){
- n++;
- counter2=0;
- for(int j=1; j<=32; j++){
- if (n & (1 << (j - 1)))
- counter2++;
- }
- if(counter1==counter2)
- break;
- }
- cout<<"Case "<<i<<": "<<n<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment