#include <bits/stdc++.h>
const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;
int N, M, sz;
int a[MAXN];
int used[MAXN];
int timer;
int tmr = 1;
void make(int v) {
used[v] = tmr;
if (v - N >= 0&&used[v-N]!=tmr)
make(v - N);
if (v + M <= sz &&used[v+M]!=tmr)
make(v + M);
a[v] = timer++;
}
int main() {
int T ;
cin>>T;
while(T--) {
cin>>N>>M;
sz = N + M - __gcd(N, M) - 1;
timer = 0;
tmr ++;
cout << sz << endl;
for (int i = 0; i <= sz; i++) {
if (used[i] != tmr)
make(i);
}
for (int i = 0; i < sz; i++) {
cout << a[i] - a[i+1] << " ";
}
cout << endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Ok |
2 |
Correct |
2 ms |
376 KB |
Ok |
3 |
Correct |
4 ms |
420 KB |
Ok |
4 |
Correct |
2 ms |
532 KB |
Ok |
5 |
Correct |
3 ms |
600 KB |
Ok |
6 |
Correct |
2 ms |
720 KB |
Ok |
7 |
Correct |
3 ms |
720 KB |
Ok |
8 |
Correct |
2 ms |
720 KB |
Ok |
9 |
Correct |
2 ms |
720 KB |
Ok |
10 |
Correct |
2 ms |
828 KB |
Ok |
11 |
Correct |
3 ms |
828 KB |
Ok |
12 |
Correct |
2 ms |
828 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
828 KB |
Ok |
2 |
Correct |
3 ms |
828 KB |
Ok |
3 |
Correct |
2 ms |
828 KB |
Ok |
4 |
Correct |
3 ms |
828 KB |
Ok |
5 |
Correct |
2 ms |
836 KB |
Ok |
6 |
Correct |
5 ms |
836 KB |
Ok |
7 |
Correct |
13 ms |
1300 KB |
Ok |
8 |
Correct |
7 ms |
1300 KB |
Ok |
9 |
Correct |
12 ms |
1452 KB |
Ok |
10 |
Correct |
9 ms |
1452 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1452 KB |
Ok |
2 |
Correct |
2 ms |
1452 KB |
Ok |
3 |
Correct |
2 ms |
1452 KB |
Ok |
4 |
Correct |
2 ms |
1452 KB |
Ok |
5 |
Correct |
2 ms |
1452 KB |
Ok |
6 |
Correct |
2 ms |
1452 KB |
Ok |
7 |
Correct |
2 ms |
1452 KB |
Ok |
8 |
Correct |
2 ms |
1452 KB |
Ok |
9 |
Correct |
2 ms |
1452 KB |
Ok |
10 |
Correct |
2 ms |
1452 KB |
Ok |
11 |
Correct |
2 ms |
1452 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1452 KB |
Ok |
2 |
Correct |
2 ms |
1452 KB |
Ok |
3 |
Correct |
2 ms |
1452 KB |
Ok |
4 |
Correct |
2 ms |
1452 KB |
Ok |
5 |
Correct |
2 ms |
1452 KB |
Ok |
6 |
Correct |
107 ms |
10432 KB |
Ok |
7 |
Correct |
80 ms |
10432 KB |
Ok |
8 |
Correct |
147 ms |
12080 KB |
Ok |
9 |
Correct |
125 ms |
12080 KB |
Ok |
10 |
Correct |
75 ms |
12080 KB |
Ok |
11 |
Correct |
114 ms |
13520 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Ok |
2 |
Correct |
2 ms |
376 KB |
Ok |
3 |
Correct |
4 ms |
420 KB |
Ok |
4 |
Correct |
2 ms |
532 KB |
Ok |
5 |
Correct |
3 ms |
600 KB |
Ok |
6 |
Correct |
2 ms |
720 KB |
Ok |
7 |
Correct |
3 ms |
720 KB |
Ok |
8 |
Correct |
2 ms |
720 KB |
Ok |
9 |
Correct |
2 ms |
720 KB |
Ok |
10 |
Correct |
2 ms |
828 KB |
Ok |
11 |
Correct |
3 ms |
828 KB |
Ok |
12 |
Correct |
2 ms |
828 KB |
Ok |
13 |
Correct |
2 ms |
1452 KB |
Ok |
14 |
Correct |
2 ms |
1452 KB |
Ok |
15 |
Correct |
2 ms |
1452 KB |
Ok |
16 |
Correct |
2 ms |
1452 KB |
Ok |
17 |
Correct |
2 ms |
1452 KB |
Ok |
18 |
Correct |
2 ms |
1452 KB |
Ok |
19 |
Correct |
2 ms |
1452 KB |
Ok |
20 |
Correct |
2 ms |
1452 KB |
Ok |
21 |
Correct |
2 ms |
1452 KB |
Ok |
22 |
Correct |
2 ms |
1452 KB |
Ok |
23 |
Correct |
2 ms |
1452 KB |
Ok |
24 |
Correct |
16 ms |
13520 KB |
Ok |
25 |
Correct |
4 ms |
13520 KB |
Ok |
26 |
Correct |
3 ms |
13520 KB |
Ok |
27 |
Correct |
4 ms |
13520 KB |
Ok |
28 |
Correct |
5 ms |
13520 KB |
Ok |
29 |
Correct |
4 ms |
13520 KB |
Ok |
30 |
Correct |
4 ms |
13520 KB |
Ok |
31 |
Correct |
4 ms |
13520 KB |
Ok |
32 |
Correct |
4 ms |
13520 KB |
Ok |
33 |
Correct |
4 ms |
13520 KB |
Ok |
34 |
Correct |
6 ms |
13520 KB |
Ok |
35 |
Correct |
6 ms |
13520 KB |
Ok |
36 |
Correct |
7 ms |
13520 KB |
Ok |
37 |
Correct |
6 ms |
13520 KB |
Ok |
38 |
Correct |
7 ms |
13520 KB |
Ok |
39 |
Correct |
6 ms |
13520 KB |
Ok |
40 |
Correct |
6 ms |
13520 KB |
Ok |
41 |
Correct |
7 ms |
13520 KB |
Ok |
42 |
Correct |
7 ms |
13520 KB |
Ok |
43 |
Correct |
16 ms |
13520 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Ok |
2 |
Correct |
2 ms |
376 KB |
Ok |
3 |
Correct |
4 ms |
420 KB |
Ok |
4 |
Correct |
2 ms |
532 KB |
Ok |
5 |
Correct |
3 ms |
600 KB |
Ok |
6 |
Correct |
2 ms |
720 KB |
Ok |
7 |
Correct |
3 ms |
720 KB |
Ok |
8 |
Correct |
2 ms |
720 KB |
Ok |
9 |
Correct |
2 ms |
720 KB |
Ok |
10 |
Correct |
2 ms |
828 KB |
Ok |
11 |
Correct |
3 ms |
828 KB |
Ok |
12 |
Correct |
2 ms |
828 KB |
Ok |
13 |
Correct |
2 ms |
828 KB |
Ok |
14 |
Correct |
3 ms |
828 KB |
Ok |
15 |
Correct |
2 ms |
828 KB |
Ok |
16 |
Correct |
3 ms |
828 KB |
Ok |
17 |
Correct |
2 ms |
836 KB |
Ok |
18 |
Correct |
5 ms |
836 KB |
Ok |
19 |
Correct |
13 ms |
1300 KB |
Ok |
20 |
Correct |
7 ms |
1300 KB |
Ok |
21 |
Correct |
12 ms |
1452 KB |
Ok |
22 |
Correct |
9 ms |
1452 KB |
Ok |
23 |
Correct |
2 ms |
1452 KB |
Ok |
24 |
Correct |
2 ms |
1452 KB |
Ok |
25 |
Correct |
2 ms |
1452 KB |
Ok |
26 |
Correct |
2 ms |
1452 KB |
Ok |
27 |
Correct |
2 ms |
1452 KB |
Ok |
28 |
Correct |
2 ms |
1452 KB |
Ok |
29 |
Correct |
2 ms |
1452 KB |
Ok |
30 |
Correct |
2 ms |
1452 KB |
Ok |
31 |
Correct |
2 ms |
1452 KB |
Ok |
32 |
Correct |
2 ms |
1452 KB |
Ok |
33 |
Correct |
2 ms |
1452 KB |
Ok |
34 |
Correct |
16 ms |
13520 KB |
Ok |
35 |
Correct |
4 ms |
13520 KB |
Ok |
36 |
Correct |
3 ms |
13520 KB |
Ok |
37 |
Correct |
4 ms |
13520 KB |
Ok |
38 |
Correct |
5 ms |
13520 KB |
Ok |
39 |
Correct |
4 ms |
13520 KB |
Ok |
40 |
Correct |
4 ms |
13520 KB |
Ok |
41 |
Correct |
4 ms |
13520 KB |
Ok |
42 |
Correct |
4 ms |
13520 KB |
Ok |
43 |
Correct |
4 ms |
13520 KB |
Ok |
44 |
Correct |
6 ms |
13520 KB |
Ok |
45 |
Correct |
6 ms |
13520 KB |
Ok |
46 |
Correct |
7 ms |
13520 KB |
Ok |
47 |
Correct |
6 ms |
13520 KB |
Ok |
48 |
Correct |
7 ms |
13520 KB |
Ok |
49 |
Correct |
6 ms |
13520 KB |
Ok |
50 |
Correct |
6 ms |
13520 KB |
Ok |
51 |
Correct |
7 ms |
13520 KB |
Ok |
52 |
Correct |
7 ms |
13520 KB |
Ok |
53 |
Correct |
16 ms |
13520 KB |
Ok |
54 |
Correct |
75 ms |
13520 KB |
Ok |
55 |
Correct |
74 ms |
13520 KB |
Ok |
56 |
Correct |
93 ms |
13520 KB |
Ok |
57 |
Correct |
64 ms |
13520 KB |
Ok |
58 |
Correct |
77 ms |
13520 KB |
Ok |
59 |
Correct |
70 ms |
13520 KB |
Ok |
60 |
Correct |
62 ms |
13520 KB |
Ok |
61 |
Correct |
58 ms |
13520 KB |
Ok |
62 |
Correct |
76 ms |
13520 KB |
Ok |
63 |
Correct |
86 ms |
13520 KB |
Ok |
64 |
Correct |
89 ms |
13520 KB |
Ok |
65 |
Correct |
78 ms |
13520 KB |
Ok |
66 |
Correct |
67 ms |
13520 KB |
Ok |
67 |
Correct |
64 ms |
13520 KB |
Ok |
68 |
Correct |
72 ms |
13520 KB |
Ok |
69 |
Correct |
156 ms |
13520 KB |
Ok |
70 |
Correct |
137 ms |
13520 KB |
Ok |
71 |
Correct |
132 ms |
13520 KB |
Ok |
72 |
Correct |
131 ms |
13520 KB |
Ok |
73 |
Correct |
149 ms |
13520 KB |
Ok |
74 |
Correct |
145 ms |
13520 KB |
Ok |
75 |
Correct |
197 ms |
13520 KB |
Ok |
76 |
Correct |
154 ms |
13520 KB |
Ok |
77 |
Correct |
208 ms |
13520 KB |
Ok |
78 |
Correct |
149 ms |
13520 KB |
Ok |
79 |
Correct |
150 ms |
13520 KB |
Ok |
80 |
Correct |
145 ms |
13520 KB |
Ok |
81 |
Correct |
165 ms |
13520 KB |
Ok |
82 |
Correct |
150 ms |
13520 KB |
Ok |
83 |
Correct |
154 ms |
13520 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Ok |
2 |
Correct |
2 ms |
376 KB |
Ok |
3 |
Correct |
4 ms |
420 KB |
Ok |
4 |
Correct |
2 ms |
532 KB |
Ok |
5 |
Correct |
3 ms |
600 KB |
Ok |
6 |
Correct |
2 ms |
720 KB |
Ok |
7 |
Correct |
3 ms |
720 KB |
Ok |
8 |
Correct |
2 ms |
720 KB |
Ok |
9 |
Correct |
2 ms |
720 KB |
Ok |
10 |
Correct |
2 ms |
828 KB |
Ok |
11 |
Correct |
3 ms |
828 KB |
Ok |
12 |
Correct |
2 ms |
828 KB |
Ok |
13 |
Correct |
2 ms |
828 KB |
Ok |
14 |
Correct |
3 ms |
828 KB |
Ok |
15 |
Correct |
2 ms |
828 KB |
Ok |
16 |
Correct |
3 ms |
828 KB |
Ok |
17 |
Correct |
2 ms |
836 KB |
Ok |
18 |
Correct |
5 ms |
836 KB |
Ok |
19 |
Correct |
13 ms |
1300 KB |
Ok |
20 |
Correct |
7 ms |
1300 KB |
Ok |
21 |
Correct |
12 ms |
1452 KB |
Ok |
22 |
Correct |
9 ms |
1452 KB |
Ok |
23 |
Correct |
2 ms |
1452 KB |
Ok |
24 |
Correct |
2 ms |
1452 KB |
Ok |
25 |
Correct |
2 ms |
1452 KB |
Ok |
26 |
Correct |
2 ms |
1452 KB |
Ok |
27 |
Correct |
2 ms |
1452 KB |
Ok |
28 |
Correct |
2 ms |
1452 KB |
Ok |
29 |
Correct |
2 ms |
1452 KB |
Ok |
30 |
Correct |
2 ms |
1452 KB |
Ok |
31 |
Correct |
2 ms |
1452 KB |
Ok |
32 |
Correct |
2 ms |
1452 KB |
Ok |
33 |
Correct |
2 ms |
1452 KB |
Ok |
34 |
Correct |
3 ms |
1452 KB |
Ok |
35 |
Correct |
2 ms |
1452 KB |
Ok |
36 |
Correct |
2 ms |
1452 KB |
Ok |
37 |
Correct |
2 ms |
1452 KB |
Ok |
38 |
Correct |
2 ms |
1452 KB |
Ok |
39 |
Correct |
107 ms |
10432 KB |
Ok |
40 |
Correct |
80 ms |
10432 KB |
Ok |
41 |
Correct |
147 ms |
12080 KB |
Ok |
42 |
Correct |
125 ms |
12080 KB |
Ok |
43 |
Correct |
75 ms |
12080 KB |
Ok |
44 |
Correct |
114 ms |
13520 KB |
Ok |
45 |
Correct |
16 ms |
13520 KB |
Ok |
46 |
Correct |
4 ms |
13520 KB |
Ok |
47 |
Correct |
3 ms |
13520 KB |
Ok |
48 |
Correct |
4 ms |
13520 KB |
Ok |
49 |
Correct |
5 ms |
13520 KB |
Ok |
50 |
Correct |
4 ms |
13520 KB |
Ok |
51 |
Correct |
4 ms |
13520 KB |
Ok |
52 |
Correct |
4 ms |
13520 KB |
Ok |
53 |
Correct |
4 ms |
13520 KB |
Ok |
54 |
Correct |
4 ms |
13520 KB |
Ok |
55 |
Correct |
6 ms |
13520 KB |
Ok |
56 |
Correct |
6 ms |
13520 KB |
Ok |
57 |
Correct |
7 ms |
13520 KB |
Ok |
58 |
Correct |
6 ms |
13520 KB |
Ok |
59 |
Correct |
7 ms |
13520 KB |
Ok |
60 |
Correct |
6 ms |
13520 KB |
Ok |
61 |
Correct |
6 ms |
13520 KB |
Ok |
62 |
Correct |
7 ms |
13520 KB |
Ok |
63 |
Correct |
7 ms |
13520 KB |
Ok |
64 |
Correct |
16 ms |
13520 KB |
Ok |
65 |
Correct |
75 ms |
13520 KB |
Ok |
66 |
Correct |
74 ms |
13520 KB |
Ok |
67 |
Correct |
93 ms |
13520 KB |
Ok |
68 |
Correct |
64 ms |
13520 KB |
Ok |
69 |
Correct |
77 ms |
13520 KB |
Ok |
70 |
Correct |
70 ms |
13520 KB |
Ok |
71 |
Correct |
62 ms |
13520 KB |
Ok |
72 |
Correct |
58 ms |
13520 KB |
Ok |
73 |
Correct |
76 ms |
13520 KB |
Ok |
74 |
Correct |
86 ms |
13520 KB |
Ok |
75 |
Correct |
89 ms |
13520 KB |
Ok |
76 |
Correct |
78 ms |
13520 KB |
Ok |
77 |
Correct |
67 ms |
13520 KB |
Ok |
78 |
Correct |
64 ms |
13520 KB |
Ok |
79 |
Correct |
72 ms |
13520 KB |
Ok |
80 |
Correct |
156 ms |
13520 KB |
Ok |
81 |
Correct |
137 ms |
13520 KB |
Ok |
82 |
Correct |
132 ms |
13520 KB |
Ok |
83 |
Correct |
131 ms |
13520 KB |
Ok |
84 |
Correct |
149 ms |
13520 KB |
Ok |
85 |
Correct |
145 ms |
13520 KB |
Ok |
86 |
Correct |
197 ms |
13520 KB |
Ok |
87 |
Correct |
154 ms |
13520 KB |
Ok |
88 |
Correct |
208 ms |
13520 KB |
Ok |
89 |
Correct |
149 ms |
13520 KB |
Ok |
90 |
Correct |
150 ms |
13520 KB |
Ok |
91 |
Correct |
145 ms |
13520 KB |
Ok |
92 |
Correct |
165 ms |
13520 KB |
Ok |
93 |
Correct |
150 ms |
13520 KB |
Ok |
94 |
Correct |
154 ms |
13520 KB |
Ok |
95 |
Correct |
235 ms |
13520 KB |
Ok |
96 |
Correct |
250 ms |
13520 KB |
Ok |
97 |
Correct |
261 ms |
13520 KB |
Ok |
98 |
Correct |
188 ms |
13520 KB |
Ok |
99 |
Correct |
270 ms |
13520 KB |
Ok |
100 |
Correct |
289 ms |
13520 KB |
Ok |
101 |
Correct |
288 ms |
13520 KB |
Ok |
102 |
Correct |
242 ms |
13520 KB |
Ok |
103 |
Correct |
391 ms |
13520 KB |
Ok |
104 |
Correct |
338 ms |
13520 KB |
Ok |
105 |
Correct |
253 ms |
13520 KB |
Ok |
106 |
Correct |
271 ms |
13520 KB |
Ok |
107 |
Correct |
241 ms |
13520 KB |
Ok |
108 |
Correct |
333 ms |
13520 KB |
Ok |
109 |
Correct |
268 ms |
13520 KB |
Ok |
110 |
Correct |
599 ms |
42364 KB |
Ok |
111 |
Correct |
807 ms |
43472 KB |
Ok |
112 |
Correct |
714 ms |
43472 KB |
Ok |
113 |
Correct |
688 ms |
43472 KB |
Ok |
114 |
Correct |
663 ms |
43472 KB |
Ok |
115 |
Correct |
722 ms |
43504 KB |
Ok |
116 |
Correct |
689 ms |
43504 KB |
Ok |
117 |
Correct |
674 ms |
43504 KB |
Ok |
118 |
Correct |
631 ms |
43504 KB |
Ok |
119 |
Correct |
719 ms |
43504 KB |
Ok |
120 |
Correct |
775 ms |
43504 KB |
Ok |
121 |
Correct |
695 ms |
43504 KB |
Ok |
122 |
Correct |
798 ms |
43504 KB |
Ok |
123 |
Correct |
665 ms |
43504 KB |
Ok |
124 |
Correct |
669 ms |
43504 KB |
Ok |
125 |
Correct |
437 ms |
43504 KB |
Ok |