#include<bits/stdc++.h>
using namespace std;
#define PB push_back
const int MAXN = 1e6 + 7;
const int logo = 20;
const int inf = 1e9 + 7;
typedef vector<int> vi;
int pf[MAXN];
int tim = 1, n, m, sol;
void dfs(int u){
if(u - n >= 0) dfs(u - n);
if(u + m <= sol) dfs(u + m);
pf[u] = tim++;
}
void solve(){
tim = 1;
cin >> n >> m;
sol = n + m - 1 - __gcd(n, m);
for(int i=0; i<=sol; i++) pf[i] = 0;
for(int i=0; i<=sol; i++) if(!pf[i]) dfs(i);
cout << sol << "\n";
for(int i=0; i<sol; i++) cout << pf[i] - pf[i + 1] << " ";
cout << "\n";
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t = 1;
cin >> t;
while(t--) solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Ok |
2 |
Correct |
1 ms |
212 KB |
Ok |
3 |
Correct |
1 ms |
332 KB |
Ok |
4 |
Correct |
0 ms |
212 KB |
Ok |
5 |
Correct |
1 ms |
212 KB |
Ok |
6 |
Correct |
1 ms |
212 KB |
Ok |
7 |
Correct |
1 ms |
212 KB |
Ok |
8 |
Correct |
1 ms |
332 KB |
Ok |
9 |
Correct |
1 ms |
332 KB |
Ok |
10 |
Correct |
1 ms |
212 KB |
Ok |
11 |
Correct |
1 ms |
212 KB |
Ok |
12 |
Correct |
1 ms |
328 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Ok |
2 |
Correct |
0 ms |
212 KB |
Ok |
3 |
Correct |
0 ms |
332 KB |
Ok |
4 |
Correct |
1 ms |
212 KB |
Ok |
5 |
Correct |
1 ms |
212 KB |
Ok |
6 |
Correct |
21 ms |
340 KB |
Ok |
7 |
Correct |
472 ms |
904 KB |
Ok |
8 |
Correct |
133 ms |
540 KB |
Ok |
9 |
Correct |
443 ms |
972 KB |
Ok |
10 |
Correct |
243 ms |
700 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Ok |
2 |
Correct |
1 ms |
212 KB |
Ok |
3 |
Correct |
1 ms |
336 KB |
Ok |
4 |
Correct |
0 ms |
212 KB |
Ok |
5 |
Correct |
1 ms |
328 KB |
Ok |
6 |
Correct |
1 ms |
212 KB |
Ok |
7 |
Correct |
1 ms |
336 KB |
Ok |
8 |
Correct |
1 ms |
212 KB |
Ok |
9 |
Correct |
1 ms |
212 KB |
Ok |
10 |
Correct |
1 ms |
212 KB |
Ok |
11 |
Correct |
1 ms |
212 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Ok |
2 |
Correct |
1 ms |
212 KB |
Ok |
3 |
Correct |
1 ms |
212 KB |
Ok |
4 |
Correct |
1 ms |
212 KB |
Ok |
5 |
Correct |
0 ms |
212 KB |
Ok |
6 |
Execution timed out |
2081 ms |
3276 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Ok |
2 |
Correct |
1 ms |
212 KB |
Ok |
3 |
Correct |
1 ms |
332 KB |
Ok |
4 |
Correct |
0 ms |
212 KB |
Ok |
5 |
Correct |
1 ms |
212 KB |
Ok |
6 |
Correct |
1 ms |
212 KB |
Ok |
7 |
Correct |
1 ms |
212 KB |
Ok |
8 |
Correct |
1 ms |
332 KB |
Ok |
9 |
Correct |
1 ms |
332 KB |
Ok |
10 |
Correct |
1 ms |
212 KB |
Ok |
11 |
Correct |
1 ms |
212 KB |
Ok |
12 |
Correct |
1 ms |
328 KB |
Ok |
13 |
Correct |
1 ms |
332 KB |
Ok |
14 |
Correct |
1 ms |
212 KB |
Ok |
15 |
Correct |
1 ms |
336 KB |
Ok |
16 |
Correct |
0 ms |
212 KB |
Ok |
17 |
Correct |
1 ms |
328 KB |
Ok |
18 |
Correct |
1 ms |
212 KB |
Ok |
19 |
Correct |
1 ms |
336 KB |
Ok |
20 |
Correct |
1 ms |
212 KB |
Ok |
21 |
Correct |
1 ms |
212 KB |
Ok |
22 |
Correct |
1 ms |
212 KB |
Ok |
23 |
Correct |
1 ms |
212 KB |
Ok |
24 |
Correct |
2 ms |
340 KB |
Ok |
25 |
Correct |
2 ms |
328 KB |
Ok |
26 |
Correct |
2 ms |
336 KB |
Ok |
27 |
Correct |
2 ms |
340 KB |
Ok |
28 |
Correct |
2 ms |
340 KB |
Ok |
29 |
Correct |
2 ms |
332 KB |
Ok |
30 |
Correct |
2 ms |
332 KB |
Ok |
31 |
Correct |
2 ms |
340 KB |
Ok |
32 |
Correct |
2 ms |
340 KB |
Ok |
33 |
Correct |
2 ms |
328 KB |
Ok |
34 |
Correct |
6 ms |
468 KB |
Ok |
35 |
Correct |
6 ms |
468 KB |
Ok |
36 |
Correct |
13 ms |
468 KB |
Ok |
37 |
Correct |
7 ms |
468 KB |
Ok |
38 |
Correct |
5 ms |
468 KB |
Ok |
39 |
Correct |
5 ms |
456 KB |
Ok |
40 |
Correct |
7 ms |
468 KB |
Ok |
41 |
Correct |
5 ms |
468 KB |
Ok |
42 |
Correct |
6 ms |
568 KB |
Ok |
43 |
Correct |
7 ms |
468 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Ok |
2 |
Correct |
1 ms |
212 KB |
Ok |
3 |
Correct |
1 ms |
332 KB |
Ok |
4 |
Correct |
0 ms |
212 KB |
Ok |
5 |
Correct |
1 ms |
212 KB |
Ok |
6 |
Correct |
1 ms |
212 KB |
Ok |
7 |
Correct |
1 ms |
212 KB |
Ok |
8 |
Correct |
1 ms |
332 KB |
Ok |
9 |
Correct |
1 ms |
332 KB |
Ok |
10 |
Correct |
1 ms |
212 KB |
Ok |
11 |
Correct |
1 ms |
212 KB |
Ok |
12 |
Correct |
1 ms |
328 KB |
Ok |
13 |
Correct |
1 ms |
212 KB |
Ok |
14 |
Correct |
0 ms |
212 KB |
Ok |
15 |
Correct |
0 ms |
332 KB |
Ok |
16 |
Correct |
1 ms |
212 KB |
Ok |
17 |
Correct |
1 ms |
212 KB |
Ok |
18 |
Correct |
21 ms |
340 KB |
Ok |
19 |
Correct |
472 ms |
904 KB |
Ok |
20 |
Correct |
133 ms |
540 KB |
Ok |
21 |
Correct |
443 ms |
972 KB |
Ok |
22 |
Correct |
243 ms |
700 KB |
Ok |
23 |
Correct |
1 ms |
332 KB |
Ok |
24 |
Correct |
1 ms |
212 KB |
Ok |
25 |
Correct |
1 ms |
336 KB |
Ok |
26 |
Correct |
0 ms |
212 KB |
Ok |
27 |
Correct |
1 ms |
328 KB |
Ok |
28 |
Correct |
1 ms |
212 KB |
Ok |
29 |
Correct |
1 ms |
336 KB |
Ok |
30 |
Correct |
1 ms |
212 KB |
Ok |
31 |
Correct |
1 ms |
212 KB |
Ok |
32 |
Correct |
1 ms |
212 KB |
Ok |
33 |
Correct |
1 ms |
212 KB |
Ok |
34 |
Correct |
2 ms |
340 KB |
Ok |
35 |
Correct |
2 ms |
328 KB |
Ok |
36 |
Correct |
2 ms |
336 KB |
Ok |
37 |
Correct |
2 ms |
340 KB |
Ok |
38 |
Correct |
2 ms |
340 KB |
Ok |
39 |
Correct |
2 ms |
332 KB |
Ok |
40 |
Correct |
2 ms |
332 KB |
Ok |
41 |
Correct |
2 ms |
340 KB |
Ok |
42 |
Correct |
2 ms |
340 KB |
Ok |
43 |
Correct |
2 ms |
328 KB |
Ok |
44 |
Correct |
6 ms |
468 KB |
Ok |
45 |
Correct |
6 ms |
468 KB |
Ok |
46 |
Correct |
13 ms |
468 KB |
Ok |
47 |
Correct |
7 ms |
468 KB |
Ok |
48 |
Correct |
5 ms |
468 KB |
Ok |
49 |
Correct |
5 ms |
456 KB |
Ok |
50 |
Correct |
7 ms |
468 KB |
Ok |
51 |
Correct |
5 ms |
468 KB |
Ok |
52 |
Correct |
6 ms |
568 KB |
Ok |
53 |
Correct |
7 ms |
468 KB |
Ok |
54 |
Correct |
69 ms |
3192 KB |
Ok |
55 |
Correct |
74 ms |
3644 KB |
Ok |
56 |
Correct |
70 ms |
3536 KB |
Ok |
57 |
Correct |
48 ms |
2696 KB |
Ok |
58 |
Correct |
58 ms |
3144 KB |
Ok |
59 |
Correct |
52 ms |
3000 KB |
Ok |
60 |
Correct |
49 ms |
2692 KB |
Ok |
61 |
Correct |
46 ms |
2704 KB |
Ok |
62 |
Correct |
62 ms |
3512 KB |
Ok |
63 |
Correct |
50 ms |
3008 KB |
Ok |
64 |
Correct |
79 ms |
3528 KB |
Ok |
65 |
Correct |
59 ms |
3384 KB |
Ok |
66 |
Correct |
52 ms |
3000 KB |
Ok |
67 |
Correct |
49 ms |
2776 KB |
Ok |
68 |
Correct |
56 ms |
3080 KB |
Ok |
69 |
Correct |
1143 ms |
8520 KB |
Ok |
70 |
Correct |
531 ms |
8760 KB |
Ok |
71 |
Correct |
978 ms |
8936 KB |
Ok |
72 |
Execution timed out |
2067 ms |
5308 KB |
Time limit exceeded |
73 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Ok |
2 |
Correct |
1 ms |
212 KB |
Ok |
3 |
Correct |
1 ms |
332 KB |
Ok |
4 |
Correct |
0 ms |
212 KB |
Ok |
5 |
Correct |
1 ms |
212 KB |
Ok |
6 |
Correct |
1 ms |
212 KB |
Ok |
7 |
Correct |
1 ms |
212 KB |
Ok |
8 |
Correct |
1 ms |
332 KB |
Ok |
9 |
Correct |
1 ms |
332 KB |
Ok |
10 |
Correct |
1 ms |
212 KB |
Ok |
11 |
Correct |
1 ms |
212 KB |
Ok |
12 |
Correct |
1 ms |
328 KB |
Ok |
13 |
Correct |
1 ms |
212 KB |
Ok |
14 |
Correct |
0 ms |
212 KB |
Ok |
15 |
Correct |
0 ms |
332 KB |
Ok |
16 |
Correct |
1 ms |
212 KB |
Ok |
17 |
Correct |
1 ms |
212 KB |
Ok |
18 |
Correct |
21 ms |
340 KB |
Ok |
19 |
Correct |
472 ms |
904 KB |
Ok |
20 |
Correct |
133 ms |
540 KB |
Ok |
21 |
Correct |
443 ms |
972 KB |
Ok |
22 |
Correct |
243 ms |
700 KB |
Ok |
23 |
Correct |
1 ms |
332 KB |
Ok |
24 |
Correct |
1 ms |
212 KB |
Ok |
25 |
Correct |
1 ms |
336 KB |
Ok |
26 |
Correct |
0 ms |
212 KB |
Ok |
27 |
Correct |
1 ms |
328 KB |
Ok |
28 |
Correct |
1 ms |
212 KB |
Ok |
29 |
Correct |
1 ms |
336 KB |
Ok |
30 |
Correct |
1 ms |
212 KB |
Ok |
31 |
Correct |
1 ms |
212 KB |
Ok |
32 |
Correct |
1 ms |
212 KB |
Ok |
33 |
Correct |
1 ms |
212 KB |
Ok |
34 |
Correct |
1 ms |
328 KB |
Ok |
35 |
Correct |
1 ms |
212 KB |
Ok |
36 |
Correct |
1 ms |
212 KB |
Ok |
37 |
Correct |
1 ms |
212 KB |
Ok |
38 |
Correct |
0 ms |
212 KB |
Ok |
39 |
Execution timed out |
2081 ms |
3276 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |