fork(2) download
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. /*======================================= Macro Start====================================================*/
  6.  
  7. #define input freopen("in.txt","r",stdin)
  8. #define output freopen("out.txt","w",stdout)
  9.  
  10. #define min3(a,b,c) min(a,min(b,c))
  11. #define max3(a,b,c) max(a,max(b,c))
  12. #define min4(a,b,c,d) min(min(a,b),min(c,d))
  13. #define max4(a,b,c,d) max(max(a,b),max(c,d))
  14. #define count_one(a) __builtin_popcount(a) // Returns the number of set bits(1) in a number(a). In long long use __builtin_popcountll(a)
  15. #define parity(i) __builtin_parity(i) //even parity 0 and odd parity 1
  16. #define blz(a) __builtin_clz(a) //Returns the number of leading zeroes in a number(a)
  17. #define btz(a) __builtin_ctz(a) //Returns the number of trailing zeroes in a number(a)
  18. #define gcd(a,b) __gcd(a,b)
  19. #define lcm(a,b) (a*(b/gcd(a,b)))
  20.  
  21. /*======================================= Macro End====================================================*/
  22.  
  23. /*====================================== CONSTANT Start===================================================*/
  24.  
  25. #define INF (1<<30) //infinity value
  26. #define EPS 1e-9
  27. #define MOD 10007
  28. #define SIZ 1005
  29.  
  30. /*====================================== CONSTANT End===================================================*/
  31.  
  32. int main()
  33. {
  34. ios_base::sync_with_stdio(0);
  35.  
  36. int tc,cn;
  37. long long n;
  38.  
  39. cin>>tc;
  40. for(cn=1;cn<=tc;cn++)
  41. {
  42. cin>>n;
  43. bitset<32>to_binary(n);
  44. int n_1_count = to_binary.count();
  45.  
  46. for(long long i=n+1;;i++)
  47. {
  48. bitset<32>next_binary(i);
  49.  
  50. if(next_binary.count() == n_1_count)
  51. {
  52. cout<<"Case "<<cn<<": "<<i<<endl;
  53. break;
  54. }
  55. }
  56.  
  57. }
  58.  
  59. return 0;
  60. }
  61.  
Success #stdin #stdout 0s 3232KB
stdin
Standard input is empty
stdout
Standard output is empty