fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int X = 5;
  6. cin >> X;
  7.  
  8. while (X > 0) {
  9. int N = 6;
  10. cin >> N;
  11. X--;
  12.  
  13. int reminder = 0;
  14.  
  15.  
  16. for (int i = N; i >= 1; i /= 2) {
  17. if (i % 2 == 1) {
  18. reminder++;
  19. }
  20. }
  21.  
  22. int res = 0;
  23.  
  24. for (int m = reminder; m > 0; m--)
  25. {
  26. res = res * 2 + 1;
  27. }
  28.  
  29.  
  30. cout << res << endl;
  31. }
  32.  
  33. return 0;
  34. }
  35.  
Success #stdin #stdout 0.01s 5316KB
stdin
Standard input is empty
stdout
3
3
3
3
3