fork(1) download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int64_t g(int64_t x) {
  6. while (x) {
  7. while (1 - (1 + ~(x % -2)) & 1)
  8. x = (int64_t)floor(x / 2.0);
  9. break;
  10. }
  11. while (1 - x)
  12. return 5;
  13. return 0;
  14. }
  15.  
  16.  
  17. int main() {
  18.  
  19. for (int64_t n = -32; n <= 32; ++ n)
  20. cout << n << " " << g(n) << endl;
  21.  
  22. }
  23.  
  24. /*
  25. def g(x):
  26.  while x:
  27.   while 1 - (1 + ~int(x % -2)) & 1: x //= -2
  28.   break
  29.  while 1-x:
  30.   return 0
  31.  return 5*/
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
-32 5
-31 5
-30 5
-29 5
-28 5
-27 5
-26 5
-25 5
-24 5
-23 5
-22 5
-21 5
-20 5
-19 5
-18 5
-17 5
-16 5
-15 5
-14 5
-13 5
-12 5
-11 5
-10 5
-9 5
-8 5
-7 5
-6 5
-5 5
-4 5
-3 5
-2 5
-1 5
0 5
1 0
2 0
3 5
4 0
5 5
6 5
7 5
8 0
9 5
10 5
11 5
12 5
13 5
14 5
15 5
16 0
17 5
18 5
19 5
20 5
21 5
22 5
23 5
24 5
25 5
26 5
27 5
28 5
29 5
30 5
31 5
32 0