alvy10

Untitled

Nov 9th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6. int t, counter1, counter2;
  7. cin>>t;
  8.  
  9. int n;
  10.  
  11. for(int i=1; i<=t; i++){
  12. counter1=0;
  13. cin>>n;
  14.  
  15. for(int j=1; j<=32; j++){
  16. if (n & (1 << (j - 1)))
  17. counter1++;
  18. }
  19.  
  20. while(1){
  21. n++;
  22. counter2=0;
  23.  
  24. for(int j=1; j<=32; j++){
  25. if (n & (1 << (j - 1)))
  26. counter2++;
  27. }
  28.  
  29. if(counter1==counter2)
  30. break;
  31. }
  32.  
  33. cout<<"Case "<<i<<": "<<n<<endl;
  34. }
  35.  
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment