fork download
  1. #include <iostream>
  2. using namespace std;
  3. pair<int, int> dp[1000];
  4. int main() {
  5. for (int i = 1; i < 453; i++){
  6. int counter = 1;
  7. for (int j = 1; j <= i; j++){
  8. if (counter > i){
  9. dp[i].first = 0;
  10. break;
  11. }
  12. if (dp[i - counter].first == 0){
  13. dp[i].first = 1;
  14. dp[i].second = i-counter;
  15. break;
  16. }
  17. counter*=2;
  18. }
  19. }
  20. for (int i=0; i<100; i++){
  21. cout<<i<<" "<<dp[i].first<<" "<<dp[i].second<<endl;
  22. }
  23. }
Success #stdin #stdout 0s 4316KB
stdin
Standard input is empty
stdout
0 0 0
1 1 0
2 1 0
3 0 0
4 1 3
5 1 3
6 0 0
7 1 6
8 1 6
9 0 0
10 1 9
11 1 9
12 0 0
13 1 12
14 1 12
15 0 0
16 1 15
17 1 15
18 0 0
19 1 18
20 1 18
21 0 0
22 1 21
23 1 21
24 0 0
25 1 24
26 1 24
27 0 0
28 1 27
29 1 27
30 0 0
31 1 30
32 1 30
33 0 0
34 1 33
35 1 33
36 0 0
37 1 36
38 1 36
39 0 0
40 1 39
41 1 39
42 0 0
43 1 42
44 1 42
45 0 0
46 1 45
47 1 45
48 0 0
49 1 48
50 1 48
51 0 0
52 1 51
53 1 51
54 0 0
55 1 54
56 1 54
57 0 0
58 1 57
59 1 57
60 0 0
61 1 60
62 1 60
63 0 0
64 1 63
65 1 63
66 0 0
67 1 66
68 1 66
69 0 0
70 1 69
71 1 69
72 0 0
73 1 72
74 1 72
75 0 0
76 1 75
77 1 75
78 0 0
79 1 78
80 1 78
81 0 0
82 1 81
83 1 81
84 0 0
85 1 84
86 1 84
87 0 0
88 1 87
89 1 87
90 0 0
91 1 90
92 1 90
93 0 0
94 1 93
95 1 93
96 0 0
97 1 96
98 1 96
99 0 0