QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#72707#2575. Restricted ArraysCSU2023#AC ✓277ms50048kbC++141.6kb2023-01-18 09:13:392023-01-18 09:13:42

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-18 09:13:42]
  • 评测
  • 测评结果:AC
  • 用时:277ms
  • 内存:50048kb
  • [2023-01-18 09:13:39]
  • 提交

answer

#include <bits/stdc++.h>

template <class T>
inline void read(T &res)
{
	char ch; bool flag = false; res = 0;
	while (ch = getchar(), !isdigit(ch) && ch != '-');
	ch == '-' ? flag = true : res = ch ^ 48;
	while (ch = getchar(), isdigit(ch))
		res = res * 10 + ch - 48; 
}

template <class T>
inline void put(T x)
{
	if (x > 9) put(x / 10);
	putchar(x % 10 + 48); 
}
 
const int N = 1e6 + 5;
const int N2 = 2e6 + 5;
int cur[N], adj[N], dis[N], nxt[N2], to[N2], cst[N2], from[N2];
int n, q, T = 1, cm; bool vis[N], istree[N2];

template <class T>
inline T Abs(T x) {return x < 0 ? -x : x;}

inline void linkArc(int x, int y, int z)
{
	nxt[++T] = adj[x]; adj[x] = T; from[T] = x; to[T] = y; cst[T] = z;
	nxt[++T] = adj[y]; adj[y] = T; from[T] = y; to[T] = x; cst[T] = -z;
}

inline void dfs(int x)
{
	vis[x] = true;
	int y;
	for (int e = adj[x]; e; e = nxt[e])
		if (!vis[y = to[e]])
		{
			istree[e] = istree[e ^ 1] = true;
			dis[y] = dis[x] + cst[e];
			dfs(y);
		}
}

int main()
{
	read(n); read(q);
	for (int i = 1, x, y; i <= q; ++i)
	{
		read(x); read(y);
		linkArc(x, y, 1);
	}
	for (int i = 1; i <= n; ++i)
		if (!vis[i])
		{
			dis[i] = 0;
			dfs(i);	
		}
	int m =  0;
	for (int e = 2; e <= T; ++e)
		if (!istree[e])
			m = std::__gcd(m, Abs(dis[from[e]] + cst[e] - dis[to[e]]));
	if (m == 0)
	{
		put(n), putchar('\n');
		for (int i = 1; i <= n; ++i)
			put(i), putchar(' ');
	}
	else 
	{
		for (int i = 1; i <= n && i <= m; ++i)
			if (m % i == 0)
				cur[++cm] = i;	
		put(cm), putchar('\n');
		for (int i = 1; i <= cm; ++i)
			put(cur[i]), putchar(' ');
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 15644kb

input:

3 3
1 2
2 3
3 1

output:

2
1 3 

result:

ok 3 number(s): "2 1 3"

Test #2:

score: 0
Accepted
time: 1ms
memory: 15764kb

input:

5 5
1 2
2 3
3 4
4 5
1 5

output:

2
1 3 

result:

ok 3 number(s): "2 1 3"

Test #3:

score: 0
Accepted
time: 1ms
memory: 15584kb

input:

5 5
1 2
2 3
3 1
4 5
5 4

output:

1
1 

result:

ok 2 number(s): "1 1"

Test #4:

score: 0
Accepted
time: 2ms
memory: 13744kb

input:

5 1
1 2

output:

5
1 2 3 4 5 

result:

ok 6 numbers

Test #5:

score: 0
Accepted
time: 2ms
memory: 15592kb

input:

30 100
3 20
30 24
24 26
20 2
24 27
26 19
27 28
24 20
12 15
28 19
13 24
6 23
5 19
12 3
22 24
30 16
22 25
13 19
27 20
14 30
3 23
29 13
25 3
9 7
6 8
20 24
11 27
19 1
16 14
21 21
20 15
8 11
29 6
27 28
3 19
10 24
5 2
6 1
18 25
19 4
10 23
5 23
18 3
26 19
10 13
23 14
28 11
19 28
6 15
7 23
28 25
8 30
1 12
2...

output:

1
1 

result:

ok 2 number(s): "1 1"

Test #6:

score: 0
Accepted
time: 0ms
memory: 15616kb

input:

300 1000
151 103
150 103
170 195
168 79
210 299
138 44
152 217
263 79
241 261
257 75
197 296
292 158
115 250
266 12
123 8
238 38
108 183
52 256
298 47
203 248
137 33
240 213
256 201
132 228
291 248
138 14
285 116
126 136
267 11
35 238
291 264
138 13
94 202
216 177
163 211
136 95
25 102
119 68
181 18...

output:

1
1 

result:

ok 2 number(s): "1 1"

Test #7:

score: 0
Accepted
time: 2ms
memory: 15684kb

input:

3000 10000
973 1816
41 321
1446 869
2878 1009
1845 2170
937 973
537 241
424 2754
2148 551
2667 1398
367 1103
2306 1095
723 2854
1681 756
2008 792
1923 1714
2826 1250
148 256
887 1966
2758 2323
1482 1554
981 2331
987 1065
2075 1884
725 200
1565 1622
1231 746
1723 1230
1236 1549
1860 2075
1507 1027
16...

output:

1
1 

result:

ok 2 number(s): "1 1"

Test #8:

score: 0
Accepted
time: 10ms
memory: 16484kb

input:

30000 100000
9507 4148
28742 7519
22004 7377
7494 3499
10238 2345
12942 25667
9310 24450
24360 18277
18839 1669
15280 15095
12927 12433
27142 5951
13026 311
9600 11754
16894 7756
14261 838
24374 14218
26787 12807
15616 16670
17561 29094
16583 24444
18526 20317
18553 20743
26072 2124
2185 6361
14086 ...

output:

1
1 

result:

ok 2 number(s): "1 1"

Test #9:

score: 0
Accepted
time: 171ms
memory: 47516kb

input:

300000 1000000
249774 172530
147057 50829
236567 253049
47854 212292
133460 198836
125633 192588
281891 33774
140778 48640
100742 41970
189198 133279
269315 7059
133013 123981
36613 111461
60970 7696
63896 5697
21311 190163
188496 10885
162822 215590
218083 186866
285081 286524
123242 35980
198034 4...

output:

1
1 

result:

ok 2 number(s): "1 1"

Test #10:

score: 0
Accepted
time: 2ms
memory: 15776kb

input:

30 100
22 19
2 28
14 16
30 11
2 28
29 12
22 19
5 27
8 13
1 6
24 22
20 4
7 30
10 11
3 24
27 20
17 15
14 16
2 28
11 9
22 19
5 27
12 8
7 30
22 19
19 23
26 25
25 1
12 8
25 21
24 22
13 26
10 11
11 9
21 7
11 9
30 11
27 20
10 11
27 20
15 21
4 29
27 20
15 1
14 16
30 11
25 1
23 2
17 25
1 6
28 5
12 8
19 23
28...

output:

8
1 2 3 4 6 8 12 24 

result:

ok 9 numbers

Test #11:

score: 0
Accepted
time: 4ms
memory: 15616kb

input:

300 1000
215 14
81 196
92 279
242 189
294 229
99 274
119 103
82 213
259 222
160 158
51 109
82 213
192 286
240 172
206 166
15 277
160 158
49 244
94 86
6 15
251 194
259 222
246 117
79 234
194 67
171 300
200 171
171 300
167 273
60 145
231 83
146 19
132 48
224 232
226 78
191 10
174 121
149 299
83 252
81...

output:

20
1 2 3 4 5 6 8 10 12 15 16 20 24 30 40 48 60 80 120 240 

result:

ok 21 numbers

Test #12:

score: 0
Accepted
time: 6ms
memory: 15748kb

input:

3000 10000
1346 613
488 2191
851 2354
275 1318
1889 821
946 877
1879 384
10 1841
801 2924
2237 1054
2140 1368
1007 1635
323 2980
1517 1576
2358 1261
2317 624
2832 2365
2910 1956
2244 2960
1564 2465
426 1126
355 2060
2133 2512
1452 2129
2884 2410
290 1056
259 602
2068 2985
2782 1520
848 1419
943 824
...

output:

48
1 2 3 4 5 6 7 8 9 10 12 14 15 18 20 21 24 28 30 35 36 40 42 45 56 60 63 70 72 84 90 105 120 126 140 168 180 210 252 280 315 360 420 504 630 840 1260 2520 

result:

ok 49 numbers

Test #13:

score: 0
Accepted
time: 12ms
memory: 20576kb

input:

30000 100000
27763 27613
18741 22824
22122 19637
11395 1271
19897 2209
26279 11087
5539 18909
13336 11727
5590 28203
3117 24690
13407 10952
13973 17613
2556 568
25401 27125
4987 27767
18068 25667
15097 16341
12826 19732
682 20475
11755 6501
5998 23752
1148 8092
3726 29463
23528 4735
12687 17530
2948...

output:

96
1 2 3 4 5 6 7 8 9 10 11 12 14 15 18 20 21 22 24 28 30 33 35 36 40 42 44 45 55 56 60 63 66 70 72 77 84 88 90 99 105 110 120 126 132 140 154 165 168 180 198 210 220 231 252 264 280 308 315 330 360 385 396 420 440 462 495 504 616 630 660 693 770 792 840 924 990 1155 1260 1320 1386 1540 1848 1980 231...

result:

ok 97 numbers

Test #14:

score: 0
Accepted
time: 204ms
memory: 48552kb

input:

300000 1000000
95735 7078
271979 37223
50786 10310
217441 245346
229845 227925
242582 42827
165670 64385
181116 137966
245475 297918
173565 24747
30795 91894
84189 253442
37632 38718
59779 74589
23315 23433
281979 211022
158778 101311
236318 245
170058 23297
251247 46053
133822 94039
94988 67932
984...

output:

180
1 2 3 4 5 6 7 8 9 10 11 12 14 15 16 18 20 21 22 24 25 28 30 33 35 36 40 42 44 45 48 50 55 56 60 63 66 70 72 75 77 80 84 88 90 99 100 105 110 112 120 126 132 140 144 150 154 165 168 175 176 180 198 200 210 220 225 231 240 252 264 275 280 300 308 315 330 336 350 360 385 396 400 420 440 450 462 495...

result:

ok 181 numbers

Test #15:

score: 0
Accepted
time: 1ms
memory: 13548kb

input:

30 100
10 24
11 25
3 27
6 5
10 24
13 16
19 10
14 23
21 26
8 22
10 24
1 23
30 1
15 17
3 27
16 28
6 5
19 10
18 3
4 30
2 12
2 12
6 5
10 24
14 23
23 16
24 30
17 9
2 12
11 25
15 28
13 16
14 23
23 16
7 11
12 18
3 27
4 30
19 10
11 25
21 26
16 28
6 5
24 30
15 28
7 11
21 26
20 14
10 24
21 26
16 28
8 22
23 16...

output:

30
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 

result:

ok 31 numbers

Test #16:

score: 0
Accepted
time: 5ms
memory: 13744kb

input:

300 1000
23 190
281 51
130 115
96 130
260 205
124 172
209 262
104 170
162 210
150 293
270 185
24 188
139 270
278 48
173 105
150 293
232 162
202 160
223 103
11 196
157 42
48 243
101 27
270 213
239 175
78 54
34 200
274 149
245 141
281 51
102 94
205 53
119 183
181 132
96 130
248 127
15 297
233 179
31 1...

output:

300
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

result:

ok 301 numbers

Test #17:

score: 0
Accepted
time: 0ms
memory: 13512kb

input:

3000 10000
2210 632
2005 2264
1657 829
443 155
164 2183
845 205
1156 1820
2318 2676
2193 562
2768 468
175 2265
598 1377
474 216
2459 1368
557 654
566 144
1763 2973
349 1502
543 1213
235 933
530 2944
1979 1360
2757 1750
2693 2958
2048 1532
62 1262
2966 1938
2019 2905
16 1676
1758 1096
1431 2636
463 1...

output:

3000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...

result:

ok 3001 numbers

Test #18:

score: 0
Accepted
time: 16ms
memory: 18152kb

input:

30000 100000
18214 4315
17616 3006
1500 9957
12634 3052
10430 27671
487 25711
29843 18141
28555 7933
2554 18114
15746 1275
11974 13560
13663 14964
24167 9623
25672 24453
2973 27128
11027 621
20852 9621
26463 29997
19231 4430
10963 23747
17775 12287
10598 8830
3782 10197
27703 2268
5098 6247
2798 158...

output:

30000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 10...

result:

ok 30001 numbers

Test #19:

score: 0
Accepted
time: 209ms
memory: 41544kb

input:

300000 1000000
228113 68224
216277 240476
264353 240423
17967 178024
22750 132091
295294 86468
145236 209602
207075 272667
122101 174406
212932 291930
245 43180
16788 109807
127465 109151
158389 33772
242366 279615
479 236921
130508 226643
66970 169167
198751 89420
158271 133582
26429 241462
101480 ...

output:

300000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...

result:

ok 300001 numbers

Test #20:

score: 0
Accepted
time: 1ms
memory: 15592kb

input:

30 100
24 4
29 12
8 29
14 6
25 28
19 11
12 14
18 15
4 1
5 26
20 28
15 27
9 29
3 19
21 8
6 4
29 12
22 6
23 10
24 2
10 16
20 28
11 7
14 6
30 20
11 7
30 20
19 11
19 11
25 28
26 22
1 18
9 5
2 1
25 28
14 6
5 26
10 16
21 8
5 26
25 28
11 7
20 23
29 12
2 1
11 7
26 14
16 8
14 6
16 8
22 6
29 12
22 6
24 4
11 2...

output:

4
1 3 5 15 

result:

ok 5 number(s): "4 1 3 5 15"

Test #21:

score: 0
Accepted
time: 5ms
memory: 13604kb

input:

300 1000
2 218
104 37
253 138
251 143
285 41
278 240
99 90
64 84
106 254
149 207
263 282
113 153
78 64
237 253
154 55
155 18
13 112
40 94
200 177
32 151
215 230
98 283
175 179
67 185
111 33
75 160
227 239
218 244
216 273
291 180
201 285
149 207
249 31
63 248
113 155
85 238
221 39
59 113
197 48
89 23...

output:

300
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

result:

ok 301 numbers

Test #22:

score: 0
Accepted
time: 2ms
memory: 13624kb

input:

3000 10000
1013 1738
1770 385
819 2824
2412 1763
2561 720
1895 319
1794 2266
1949 2353
1093 730
2015 2968
1265 1853
112 861
1390 1432
1840 338
826 860
1124 1455
2006 824
2176 644
1885 232
2286 220
1455 2226
2465 1953
1279 439
1134 2689
1156 495
1862 2182
2611 2474
1439 1049
1859 804
1603 908
2322 12...

output:

3000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...

result:

ok 3001 numbers

Test #23:

score: 0
Accepted
time: 6ms
memory: 18000kb

input:

30000 100000
4720 1845
1073 2491
24392 7585
18707 24267
9487 7108
15925 2795
22293 12942
1014 10410
13217 26712
11436 5488
4629 11166
25209 25432
18776 28655
27499 1081
11838 19886
26315 6467
13390 25190
23048 4689
12639 22546
9871 27608
26162 25552
25219 23717
25637 1561
2635 15079
28198 27344
1694...

output:

30000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 10...

result:

ok 30001 numbers

Test #24:

score: 0
Accepted
time: 175ms
memory: 41300kb

input:

300000 1000000
154890 207328
212989 81445
215910 292481
264511 150983
221181 286578
68712 212871
7002 148843
208707 187650
83520 189920
16527 183771
193282 179107
68753 124330
251718 153788
107645 224463
220791 55311
111102 194192
298218 115909
163131 109508
159617 65057
62376 196567
66220 283562
11...

output:

300000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...

result:

ok 300001 numbers

Test #25:

score: 0
Accepted
time: 2ms
memory: 15600kb

input:

20 1000
13 18
19 1
1 14
15 8
1 14
7 15
18 10
3 6
2 8
16 20
19 1
15 8
13 18
2 8
13 18
2 3
20 12
7 15
20 7
1 14
3 6
18 10
10 19
17 9
2 8
16 20
2 8
6 11
6 11
10 19
2 8
20 7
5 16
13 18
13 18
20 12
1 14
11 13
16 9
20 7
6 11
20 7
14 17
1 14
1 14
16 9
12 2
10 19
12 15
17 9
5 16
14 17
14 17
13 18
10 19
12 2...

output:

2
1 13 

result:

ok 3 number(s): "2 1 13"

Test #26:

score: 0
Accepted
time: 0ms
memory: 15604kb

input:

200 10000
18 176
7 138
147 190
123 67
156 33
69 64
27 181
73 183
87 34
184 113
124 28
86 141
124 28
26 148
82 89
136 110
88 5
164 184
38 148
77 141
113 147
159 35
105 150
73 183
174 127
13 168
72 68
40 74
48 39
41 172
145 179
198 118
33 41
194 199
180 17
14 95
115 58
148 188
31 175
194 199
14 95
71 ...

output:

12
1 2 3 4 6 8 9 12 18 24 36 72 

result:

ok 13 numbers

Test #27:

score: 0
Accepted
time: 6ms
memory: 17720kb

input:

2000 100000
2000 1549
441 276
1859 125
279 890
993 474
1910 602
1470 596
239 777
1712 1596
1273 388
62 1399
120 224
1555 931
279 890
1667 263
1907 1967
1403 33
1626 960
588 664
1078 1565
623 1819
1213 396
1974 1871
586 1951
1575 429
1580 730
1626 960
1711 1365
1984 1300
1592 957
1893 216
982 612
174...

output:

32
1 2 3 4 6 7 8 9 12 14 18 21 24 27 28 36 42 54 56 63 72 84 108 126 168 189 216 252 378 504 756 1512 

result:

ok 33 numbers

Test #28:

score: 0
Accepted
time: 147ms
memory: 39156kb

input:

20000 1000000
6389 142
1329 15945
12283 14318
639 18821
2042 13104
2919 7276
4828 3894
3367 13012
7942 257
5354 19713
7300 18921
10782 266
12769 16854
9254 12777
13932 16062
4940 4727
5242 2506
11953 11124
1841 17698
11002 1403
12233 5823
10021 15623
1919 4927
19011 11952
18721 6821
6481 11212
12243...

output:

72
1 2 3 4 5 6 7 8 10 12 14 15 16 20 21 24 25 28 30 32 35 40 42 48 50 56 60 70 75 80 84 96 100 105 112 120 140 150 160 168 175 200 210 224 240 280 300 336 350 400 420 480 525 560 600 672 700 800 840 1050 1120 1200 1400 1680 2100 2400 2800 3360 4200 5600 8400 16800 

result:

ok 73 numbers

Test #29:

score: 0
Accepted
time: 1ms
memory: 15648kb

input:

20 10000
15 9
1 3
4 13
15 9
3 17
17 9
13 18
5 16
18 19
8 18
17 8
11 17
12 18
19 20
10 14
5 3
10 17
17 9
6 11
20 9
16 20
2 19
7 18
18 19
7 1
8 18
1 16
6 19
11 20
4 12
17 9
1 19
13 18
6 10
13 18
2 19
4 12
3 17
18 19
10 20
4 8
10 14
19 20
11 4
10 15
2 19
6 10
6 11
7 18
15 8
13 5
12 18
4 9
13 2
20 9
16 ...

output:

3
1 2 4 

result:

ok 4 number(s): "3 1 2 4"

Test #30:

score: 0
Accepted
time: 10ms
memory: 17588kb

input:

200 100000
185 65
30 148
23 57
14 38
16 107
80 37
71 154
22 178
185 65
74 194
141 196
69 22
196 26
21 134
170 121
107 20
34 78
78 172
48 142
140 37
136 167
131 27
138 122
82 188
147 165
129 74
87 172
128 197
197 75
129 74
198 41
163 162
200 160
18 118
155 101
90 168
155 101
137 149
120 138
129 74
71...

output:

12
1 2 3 5 6 9 10 15 18 30 45 90 

result:

ok 13 numbers

Test #31:

score: 0
Accepted
time: 95ms
memory: 38192kb

input:

2000 1000000
669 955
731 1832
662 1571
1879 1960
387 791
1699 1711
448 757
1937 171
1245 290
255 784
1604 1502
1959 1135
778 1535
52 1744
1287 889
295 1883
167 1487
1697 627
309 799
840 1877
309 799
667 820
1169 1530
865 110
115 1611
1367 594
547 1826
1644 783
661 1876
985 287
71 1676
533 852
176 11...

output:

36
1 2 3 4 5 6 8 9 10 12 15 18 20 24 25 30 36 40 45 50 60 72 75 90 100 120 150 180 200 225 300 360 450 600 900 1800 

result:

ok 37 numbers

Test #32:

score: 0
Accepted
time: 5ms
memory: 15628kb

input:

20 10000
8 12
14 7
17 19
2 9
19 5
13 16
5 10
7 2
14 7
10 3
3 8
10 3
16 11
20 6
13 16
17 19
3 8
19 5
16 11
14 7
7 2
5 10
14 7
13 16
6 15
7 2
8 12
4 13
14 7
5 10
10 3
16 11
2 9
20 12
9 17
2 9
3 8
18 1
2 9
12 18
18 1
7 2
18 1
18 1
13 16
18 1
14 7
16 11
6 18
13 16
17 19
9 17
15 4
14 7
14 7
20 12
15 4
12...

output:

5
1 2 4 8 16 

result:

ok 6 numbers

Test #33:

score: 0
Accepted
time: 13ms
memory: 19728kb

input:

200 100000
26 109
147 162
179 182
89 39
84 8
170 180
49 133
150 5
106 55
75 165
128 16
97 15
171 195
20 10
108 65
2 6
124 191
96 14
51 34
91 30
81 181
78 74
193 37
61 3
103 64
194 144
32 161
94 107
192 68
151 197
48 126
32 161
78 74
148 176
128 141
159 126
92 20
175 43
59 29
55 11
160 159
30 125
64 ...

output:

9
1 2 4 5 10 20 25 50 100 

result:

ok 10 numbers

Test #34:

score: 0
Accepted
time: 111ms
memory: 38180kb

input:

2000 1000000
693 1841
632 602
384 1721
1469 1559
847 293
435 1553
1207 1453
603 862
1717 197
1552 810
1190 511
888 1648
1489 1025
1871 610
308 768
235 1795
1578 594
1807 1809
417 1431
1779 1132
1389 1697
69 1979
163 1286
1435 1879
1882 1309
491 803
1070 209
1789 507
1711 1688
1775 1782
1318 422
1299...

output:

32
1 2 3 4 6 7 8 9 12 14 18 21 24 27 28 36 42 54 56 63 72 84 108 126 168 189 216 252 378 504 756 1512 

result:

ok 33 numbers

Test #35:

score: 0
Accepted
time: 0ms
memory: 15800kb

input:

20 10000
1 11
15 2
3 5
19 15
3 5
4 12
9 7
14 1
12 10
10 16
4 12
19 6
2 13
19 15
4 12
7 6
15 2
1 11
16 7
11 4
6 17
3 5
2 13
1 11
12 10
4 12
7 6
15 2
15 17
1 11
4 12
16 7
10 16
10 16
20 3
9 19
3 5
15 17
7 6
10 16
18 9
11 4
6 17
20 3
9 7
2 13
9 7
15 2
17 13
20 3
1 11
7 6
1 11
19 15
15 2
2 20
2 13
14 1
...

output:

4
1 2 7 14 

result:

ok 5 number(s): "4 1 2 7 14"

Test #36:

score: 0
Accepted
time: 9ms
memory: 17648kb

input:

200 100000
162 193
94 59
180 112
81 8
93 97
194 5
145 1
163 12
78 19
140 143
181 104
3 138
182 62
125 117
136 60
102 59
148 122
31 35
143 136
178 47
156 117
198 58
88 71
39 118
110 130
177 151
27 114
107 85
36 84
128 54
160 183
103 191
138 141
60 58
75 98
66 74
100 155
144 108
148 109
163 61
36 73
1...

output:

9
1 2 4 5 10 20 25 50 100 

result:

ok 10 numbers

Test #37:

score: 0
Accepted
time: 99ms
memory: 40244kb

input:

2000 1000000
165 646
1509 914
850 1314
366 1531
770 1463
1554 810
1023 1469
400 1075
821 52
256 251
1271 1838
1922 1355
1982 1796
1592 1071
560 1524
1929 1865
114 381
349 1210
1296 1846
680 1903
1247 1507
1859 1757
1690 1533
41 1756
909 1446
1753 1841
916 615
1686 99
1402 207
1332 936
1651 1147
1278...

output:

32
1 2 3 4 5 6 7 8 10 12 14 15 20 21 24 28 30 35 40 42 56 60 70 84 105 120 140 168 210 280 420 840 

result:

ok 33 numbers

Test #38:

score: 0
Accepted
time: 0ms
memory: 15596kb

input:

20 10000
19 3
15 11
20 1
19 3
12 9
10 15
2 16
3 13
5 7
19 3
12 9
6 18
16 4
19 3
1 14
4 6
4 6
4 6
7 12
2 16
18 19
12 9
2 16
13 9
8 10
5 3
7 12
9 17
18 19
14 2
2 16
10 15
20 17
15 18
19 3
3 13
19 3
16 4
4 6
5 3
1 14
8 10
13 9
16 4
1 14
3 13
11 5
16 4
20 1
4 6
1 14
5 3
5 7
15 18
19 3
4 6
18 19
11 5
9 1...

output:

2
1 11 

result:

ok 3 number(s): "2 1 11"

Test #39:

score: 0
Accepted
time: 5ms
memory: 19688kb

input:

200 100000
149 32
139 22
76 121
163 198
108 68
21 111
193 97
183 30
83 134
136 108
34 44
67 129
111 189
170 91
57 190
24 190
43 120
111 189
6 21
71 46
82 5
100 76
84 42
189 47
1 174
171 153
19 64
191 173
171 150
4 132
31 116
30 107
44 131
65 179
89 135
170 91
45 1
156 163
124 127
168 43
54 194
14 40...

output:

10
1 2 4 7 8 14 16 28 56 112 

result:

ok 11 numbers

Test #40:

score: 0
Accepted
time: 88ms
memory: 38240kb

input:

2000 1000000
1696 389
74 693
424 1551
920 424
505 1223
1257 690
181 239
329 1357
997 905
627 1816
902 857
770 1233
687 1170
469 306
257 1167
350 667
973 1853
983 1203
1293 1165
859 1830
1116 1632
759 1275
1259 927
1567 134
1886 275
820 1394
1553 478
1502 273
1592 1123
1310 772
1427 375
651 593
915 2...

output:

36
1 2 3 4 5 6 8 9 10 12 15 18 20 24 25 30 36 40 45 50 60 72 75 90 100 120 150 180 200 225 300 360 450 600 900 1800 

result:

ok 37 numbers

Test #41:

score: 0
Accepted
time: 2ms
memory: 15768kb

input:

20 10000
11 5
1 3
6 2
6 5
3 4
13 18
4 13
15 13
18 16
18 16
7 9
18 16
14 10
15 13
13 18
5 14
7 9
15 13
12 16
13 18
12 11
6 5
10 4
17 6
17 11
13 18
5 14
20 15
19 18
9 18
14 10
15 19
12 11
3 4
19 18
19 18
5 14
20 4
6 5
9 18
20 15
4 13
13 18
14 10
11 5
6 2
19 18
1 10
13 18
2 8
9 17
6 2
5 14
15 19
9 17
1...

output:

2
1 7 

result:

ok 3 number(s): "2 1 7"

Test #42:

score: 0
Accepted
time: 9ms
memory: 19828kb

input:

200 100000
195 41
171 29
66 85
41 123
68 116
149 18
165 97
60 84
89 112
59 101
158 120
83 114
46 25
171 29
97 95
102 12
60 84
144 168
121 146
38 64
24 57
166 149
198 136
144 168
22 87
182 193
27 130
76 167
103 47
54 158
91 141
69 150
153 191
48 110
89 112
172 168
117 154
76 152
86 145
68 116
168 46
...

output:

12
1 2 3 6 7 9 14 18 21 42 63 126 

result:

ok 13 numbers

Test #43:

score: 0
Accepted
time: 98ms
memory: 38152kb

input:

2000 1000000
405 878
674 1176
29 1388
1156 971
1315 1572
1862 1870
384 898
1391 96
740 1902
1921 1708
1336 1610
218 818
387 566
860 18
931 1980
1525 148
1871 211
986 926
1647 1302
1852 220
912 1761
1634 538
102 73
1007 447
425 974
71 414
1462 1125
1133 1160
878 1559
1764 228
275 1562
708 233
1388 11...

output:

36
1 2 3 4 5 6 8 9 10 12 15 16 18 20 24 30 32 36 40 45 48 60 72 80 90 96 120 144 160 180 240 288 360 480 720 1440 

result:

ok 37 numbers

Test #44:

score: 0
Accepted
time: 70ms
memory: 15696kb

input:

1000000 1
512646 623430

output:

1000000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 ...

result:

ok 1000001 numbers

Test #45:

score: 0
Accepted
time: 1ms
memory: 15632kb

input:

50 100
35 2
17 28
39 20
45 18
23 9
14 42
45 18
39 20
7 34
37 48
50 44
39 20
29 15
38 10
13 27
30 6
33 17
36 22
49 43
1 27
13 47
5 24
13 47
46 14
34 16
26 45
8 29
17 28
45 18
12 11
36 22
10 23
46 14
39 20
30 6
2 46
21 4
21 4
37 42
46 14
16 30
4 7
34 16
35 2
13 47
8 29
47 40
35 41
24 26
41 25
8 29
7 3...

output:

50
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 

result:

ok 51 numbers

Test #46:

score: 0
Accepted
time: 1ms
memory: 13572kb

input:

500 1000
404 276
405 401
404 276
459 124
239 38
248 253
37 449
379 221
283 202
16 41
28 252
30 475
249 479
145 131
209 137
11 152
159 137
210 477
401 114
182 428
478 287
178 383
152 317
398 214
52 237
441 116
460 462
389 26
455 347
403 353
52 237
409 338
92 223
119 463
240 27
9 95
372 338
345 43
445...

output:

500
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

result:

ok 501 numbers

Test #47:

score: 0
Accepted
time: 0ms
memory: 15676kb

input:

5000 10000
729 3210
3627 4600
1082 2733
3365 811
737 3006
821 4692
1790 4896
946 3948
4795 4471
4827 2089
2499 4895
1163 898
781 3534
2193 1418
1161 756
1271 606
3989 4444
379 2016
4253 739
573 2314
838 891
1488 1234
1314 2544
1876 2905
2313 1792
3909 3932
1827 4539
1638 4663
1784 3060
3774 3448
145...

output:

5000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...

result:

ok 5001 numbers

Test #48:

score: 0
Accepted
time: 20ms
memory: 18104kb

input:

50000 100000
2870 7265
33770 41935
15340 23922
4360 36802
45733 9727
5783 46312
11454 24657
47712 27948
42561 10934
22060 48583
9258 32635
45539 29237
5467 35793
43367 23153
21001 23958
33735 46103
18593 37003
31311 46963
20937 43294
8855 10625
36311 29147
29924 47353
48345 42096
16534 14304
38790 2...

output:

50000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 10...

result:

ok 50001 numbers

Test #49:

score: 0
Accepted
time: 206ms
memory: 42048kb

input:

500000 1000000
79473 237504
152266 263330
455832 158347
54747 313668
463684 203431
389961 252773
284504 397300
63038 284341
496003 366507
9461 309170
91239 382191
12252 114661
378867 336369
420556 245088
250636 360220
428674 84034
144347 313288
428544 256468
245716 478481
31841 169147
123088 263323
...

output:

500000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...

result:

ok 500001 numbers

Test #50:

score: 0
Accepted
time: 4ms
memory: 13680kb

input:

50 100
38 28
20 39
18 8
11 33
47 26
21 1
17 13
39 34
29 37
27 43
23 18
30 9
7 10
35 5
25 16
21 1
11 33
37 3
11 34
24 21
27 43
42 15
2 6
30 9
34 7
41 32
1 44
35 5
47 31
13 27
37 3
39 34
39 34
45 47
30 9
42 15
48 41
33 45
22 38
32 40
33 45
19 25
22 38
47 31
7 10
5 30
10 31
48 41
3 20
24 21
11 34
18 8
...

output:

50
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 

result:

ok 51 numbers

Test #51:

score: 0
Accepted
time: 0ms
memory: 13752kb

input:

500 1000
488 408
316 322
161 378
258 219
488 408
262 157
118 208
185 98
409 461
449 52
74 50
201 387
393 160
448 323
305 391
225 446
430 41
186 181
61 171
200 318
249 245
19 8
58 405
319 345
498 111
361 87
41 141
383 317
202 415
120 37
172 124
23 164
478 113
105 286
176 295
159 169
455 473
36 84
146...

output:

500
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

result:

ok 501 numbers

Test #52:

score: 0
Accepted
time: 4ms
memory: 13668kb

input:

5000 10000
1229 4781
2380 2693
3275 3406
854 1170
2785 807
1931 1439
3502 4007
4018 651
1595 4284
4885 1737
4835 1654
3767 475
1820 1620
144 4740
2517 4842
595 1163
2916 478
124 4551
4482 3895
2581 3321
4349 1965
3603 4479
281 2556
3152 2614
2546 4495
2706 1749
4976 4768
52 342
3832 1663
1512 2707
1...

output:

5000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...

result:

ok 5001 numbers

Test #53:

score: 0
Accepted
time: 9ms
memory: 16028kb

input:

50000 100000
36491 30206
34493 48161
41561 20450
27187 34637
3773 16178
40363 14424
1107 44761
15664 6620
35841 48172
16671 36057
32102 11122
6002 37911
16801 34981
13311 26034
49743 30982
4779 48187
13502 35102
40055 44655
13067 797
38058 39353
19774 11767
35297 46015
3971 44358
24193 37822
7311 11...

output:

50000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 10...

result:

ok 50001 numbers

Test #54:

score: 0
Accepted
time: 228ms
memory: 42052kb

input:

500000 1000000
204851 363783
403452 386870
136151 411615
41836 298635
49527 120320
288948 171326
183783 49560
302412 91279
230346 113048
167674 297996
260889 100157
430144 26135
45497 18773
159867 438625
431818 172789
352715 90282
294529 58899
344614 498213
110419 455932
386870 145274
31756 323372
4...

output:

500000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...

result:

ok 500001 numbers

Test #55:

score: 0
Accepted
time: 277ms
memory: 50048kb

input:

1000000 1000000
587545 345519
275910 471361
525014 684979
485304 255130
989111 268361
362676 136419
752148 13168
5947 96436
474105 543805
358212 840892
908903 58071
998138 439613
338515 244666
105084 496844
867046 402805
449308 462994
230843 426412
837665 887565
267939 916502
591876 877903
996644 25...

output:

1
1 

result:

ok 2 number(s): "1 1"