fork(4) download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. int main() {
  7. unsigned long long int a, wynik, b;
  8. int i;
  9. while ( cin >> a )
  10. {
  11. i = 0;
  12. wynik = 0;
  13. while ( a >= pow( 2, i ) && i < 64 )
  14. {
  15. i++;
  16. }
  17. i--;
  18. while ( a != 0 )
  19. {
  20. if ( a % 2 == 1 )
  21. {
  22. b = pow( 2, i );
  23. wynik += b;
  24. }
  25. i--;
  26. a = a/2;
  27.  
  28. }
  29. cout << wynik << endl;
  30. }
  31. return 0;
  32. }
Success #stdin #stdout 0s 4712KB
stdin
18446744073709551615
4294967296
4294967297
69788180
19192237
0
8070450532247928832
9223372036854775809
11
61
13
47
stdout
18446744073709551615
1
4294967297
21117089
23803465
0
7
9223372036854775809
13
47
11
61