QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#106340#3060. Cumulative CodeDeterminantAC ✓901ms12012kbC++141.3kb2023-05-17 14:26:402023-05-17 14:28:43

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-17 14:28:43]
  • 评测
  • 测评结果:AC
  • 用时:901ms
  • 内存:12012kb
  • [2023-05-17 14:26:40]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;typedef long long ll;
int n,q,d,pw[33],tg[33][14007];ll f1[33][14007],f2[33][14007],f3[33][14007];
int sol1(int o,int x,int y){
	if(y==pw[x]-1)return o/2;
	return y<pw[x-1]?sol1(o*2,x-1,y):sol1(o*2+1,x-1,y-pw[x-1]+1);
}
int sol1(int x){
	for(int i=n-1;~i;i--){
		if(x<=pw[i])return x==pw[i]?pw[n+1-i]-1:sol1(pw[n+1-i]-2,i,x);
		x-=pw[i];
	}
}
void sol2(int x,int y){
	if(x==1){f1[x][y]=(y==1||d==1);return;}if(tg[x][y]==d)return;
	int z=(y+d-(pw[x-1]-1)%d)%d;tg[x][y]=d;sol2(x-1,y);sol2(x-1,z);
	f1[x][y]=(f1[x-1][y]+f1[x-1][z])*2+((pw[x]-1)%d==y);
	f2[x][y]=f2[x-1][y]+f3[x-1][z];f3[x][y]=f2[x][y]+f1[x-1][y]+f1[x-1][z];
}
ll sol2(int o,int op,int x,int y){
	if(y>=pw[x]-1){sol2(x,y%d);return f1[x][y%d]*o+(op?f3[x][y%d]:f2[x][y%d]);}if(y<=0)return 0;
	return sol2(o*2+op,0,x-1,y)+sol2(o*2+op,1,x-1,y-pw[x-1]+1);
}
ll sol2(int x){
	ll s=0;for(int i=n-1;~i;i--){
		int u=x%d;if(x<pw[i])return s+sol2(pw[n-i]-1,0,i,x);
		sol2(i,u);s+=f1[i][u]*(pw[n-i]-1)+f2[i][u];if(pw[i]%d==u)s+=pw[n+1-i]-1;x-=pw[i];
	}
}
int main(){
	scanf("%d%d",&n,&q);for(int i=0;i<31;++i)pw[i]=(1<<i);d=1;
	for(int i=1;i<=q;++i){
		int a0,m;ll s=0;scanf("%d%d%d",&a0,&d,&m);
		if(m<=80000)for(int j=0;j<m;++j)s+=sol1(a0+j*d);
		else s=sol2(a0+(m-1)*d)-(a0<=d?0:sol2(a0-d));
		printf("%lld\n",s);
	}return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3512kb

input:

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

output:

2
2
1
3
3

result:

ok 5 lines

Test #2:

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

input:

4 4
2 1 5
4 4 3
4 8 1
10 3 2

output:

18
15
5
13

result:

ok 4 lines

Test #3:

score: 0
Accepted
time: 3ms
memory: 3572kb

input:

7 1
1 1 125

output:

4031

result:

ok single line: '4031'

Test #4:

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

input:

2 1
1 1 1

output:

1

result:

ok single line: '1'

Test #5:

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

input:

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

output:

2
2
4
5
8
11
2
3
6
2
5
2
5
2
2
3
6
9
2
5
2
5
1
1
4
7
1
4
3
3
6
3

result:

ok 32 lines

Test #6:

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

input:

4 282
1 13 1
1 1 1
1 1 2
1 1 3
1 1 4
1 1 5
1 1 6
1 1 7
1 1 8
1 1 9
1 1 10
1 1 11
1 1 12
1 1 13
1 2 1
1 2 2
1 2 3
1 2 4
1 2 5
1 2 6
1 2 7
1 3 1
1 3 2
1 3 3
1 3 4
1 3 5
1 4 1
1 4 2
1 4 3
1 4 4
1 5 1
1 5 2
1 5 3
1 6 1
1 6 2
1 6 3
1 7 1
1 7 2
1 8 1
1 8 2
1 9 1
1 9 2
1 10 1
1 10 2
1 11 1
1 11 2
1 12 1
1 ...

output:

4
4
8
10
15
20
22
23
26
32
38
41
48
55
4
6
11
12
18
21
28
4
9
10
16
23
4
9
15
22
4
6
9
4
5
12
4
7
4
10
4
10
4
7
4
11
4
11
4
4
6
11
16
18
19
22
28
34
37
44
51
4
9
11
14
20
27
4
9
12
15
4
6
12
4
5
12
4
7
4
10
4
10
4
7
4
11
4
11
2
2
7
12
14
15
18
24
30
33
40
47
2
7
8
14
17
24
2
4
10
17
2
3
6
2
5
12
2
8...

result:

ok 282 lines

Test #7:

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

input:

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

output:

14
5
5
14
41
13
14
1
15
5
55
13
10
7
16
3
14
21
1
12
11
26
24
1
10
13
8
15
2
24
54
42
21
29
29
60
16
194
47
96
57
166
95
89
171
125
21
21
122
76
36
112
44
9
71
104
87
18
96
32
21
12
133
89
98
15
19
56
26
52
14
27
46
34
51
47
5
36
39
72
28
65
25
42
29
14
35
33
41
16
56
18
17
17
22
72
18
32
32
111
46
...

result:

ok 268 lines

Test #8:

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

input:

6 267
54 29 1
48 14 1
21 54 1
46 50 1
44 26 1
20 48 1
37 40 1
47 11 1
16 40 2
15 39 1
1 25 2
19 12 2
47 32 1
19 9 5
5 52 2
18 4 6
41 32 1
32 18 1
8 33 2
9 40 2
9 40 2
38 58 1
19 37 2
46 55 1
2 51 2
43 8 2
12 40 2
11 11 5
13 10 5
54 11 1
2 2 29
27 1 25
4 1 23
17 1 21
11 1 11
46 1 12
18 3 6
47 3 3
7 1...

output:

14
7
10
6
27
21
25
3
35
2
39
22
3
70
47
76
26
3
44
46
46
12
36
6
45
41
48
82
111
14
464
391
329
320
155
210
91
60
802
176
360
19
186
438
585
184
199
504
92
135
119
61
45
84
491
503
72
235
358
316
162
64
100
12
177
95
145
35
93
105
96
57
36
90
123
44
254
65
12
130
69
130
231
616
130
109
30
71
152
68
...

result:

ok 267 lines

Test #9:

score: 0
Accepted
time: 3ms
memory: 3724kb

input:

7 290
72 99 1
109 61 1
22 92 2
71 44 1
1 33 2
12 94 1
29 96 1
67 63 1
95 72 1
103 124 1
106 71 1
69 55 2
5 77 1
32 83 1
5 19 4
22 30 2
112 118 1
50 60 1
18 90 1
107 5 2
42 110 1
71 114 1
100 119 1
33 26 1
9 30 3
17 111 1
54 34 3
62 83 1
9 100 2
87 19 1
70 1 26
4 5 15
57 3 17
85 4 11
42 1 73
4 1 97
2...

output:

50
29
69
12
52
35
9
24
3
14
29
112
33
40
116
31
15
45
18
74
43
12
57
40
125
36
162
2
63
54
875
410
617
512
2453
2895
1258
1839
505
215
2717
858
2218
1977
1535
244
700
1959
994
1414
1111
2026
1382
813
92
1848
196
923
45
1106
176
469
293
693
1337
644
1539
526
1526
426
35
112
786
875
90
362
374
133
616...

result:

ok 290 lines

Test #10:

score: 0
Accepted
time: 3ms
memory: 3572kb

input:

8 269
224 150 1
210 165 1
76 146 2
60 8 22
126 158 1
53 105 2
67 234 1
211 162 1
156 14 4
91 36 3
232 131 1
89 88 2
65 163 1
244 94 1
20 91 2
75 143 2
94 81 1
19 40 6
112 67 3
10 29 8
17 8 27
44 97 3
236 161 1
68 25 1
160 44 3
29 243 1
126 84 1
204 226 1
192 86 1
65 219 1
195 1 24
213 1 18
174 1 58
...

output:

15
58
55
1416
2
31
81
117
269
149
122
141
80
125
161
202
5
524
217
450
2090
116
123
81
282
17
2
115
7
80
2005
1346
4294
218
1393
471
5045
12854
4377
5405
809
1501
11704
1009
3404
1184
5279
5647
1250
339
1764
4283
8546
4385
1603
10152
697
5578
1653
1226
4663
4994
7297
5667
268
121
925
5549
72
1782
43...

result:

ok 269 lines

Test #11:

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

input:

9 283
55 249 2
27 504 1
91 192 2
389 419 1
45 31 5
482 15 2
287 320 1
51 434 2
192 268 2
353 311 1
281 366 1
114 384 2
383 466 1
248 346 1
368 382 1
80 347 2
382 118 1
241 168 2
362 351 1
111 188 2
124 468 1
368 65 2
108 440 1
30 179 1
371 38 3
225 110 3
94 491 1
282 215 2
388 68 1
252 178 2
81 1 24...

output:

346
135
274
225
518
500
12
390
419
108
99
409
3
191
110
383
6
304
219
359
19
228
38
16
232
426
9
451
225
40
29166
12841
169
23358
13064
33228
29580
14359
8642
15410
24227
7855
13553
7203
53452
1608
23094
5207
13875
444
20483
1116
11536
34144
24314
5483
3549
30876
10034
23476
5866
7404
6779
6217
1150...

result:

ok 283 lines

Test #12:

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

input:

10 271
610 694 1
97 899 1
461 310 2
513 780 1
80 834 1
673 407 1
122 920 1
490 303 1
247 734 2
865 60 1
576 669 1
662 765 1
844 205 1
1007 590 1
1015 669 1
11 321 3
533 315 2
613 676 1
119 923 1
973 639 1
223 194 3
38 727 1
624 551 1
500 537 1
7 404 1
347 414 1
965 946 1
463 410 2
134 529 2
539 481 ...

output:

409
140
596
384
276
212
143
94
569
236
400
422
233
63
127
447
662
102
143
249
1082
66
206
382
64
85
497
661
494
902
29529
103680
111203
62141
85155
103606
13535
183272
29440
39352
90030
63722
23614
107500
94500
133213
129603
4346
47522
51821
6844
199856
26147
37081
24740
109682
42266
84025
70876
146...

result:

ok 271 lines

Test #13:

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

input:

11 287
1995 458 1
1579 1480 1
520 1923 1
406 1747 1
1334 697 2
317 136 4
218 1531 1
849 330 1
1434 1666 1
1543 725 1
502 659 3
1206 194 2
1921 697 1
1618 1102 1
1764 375 1
980 691 1
1057 908 1
270 1741 1
98 1130 2
1871 612 1
578 1113 1
1771 275 1
355 135 10
845 1736 1
1037 1456 1
1910 375 1
874 1431...

output:

1011
907
642
614
973
1438
283
725
435
224
1523
1677
992
917
238
758
776
72
741
980
657
238
3885
724
385
990
182
855
545
657
244500
134914
147176
15945
449222
812153
185316
53530
415863
402117
564968
16593
72616
354194
205235
326339
273978
331923
345966
222126
36847
50022
416720
103366
87374
443986
2...

result:

ok 287 lines

Test #14:

score: 0
Accepted
time: 7ms
memory: 3720kb

input:

12 276
863 1831 1
1619 2607 1
3811 3252 1
3025 1920 1
534 1240 3
982 1637 2
1696 2405 1
754 2637 1
936 3943 1
3307 568 1
4075 3475 1
1413 1001 2
3366 2763 1
2241 1696 1
2033 181 10
509 1162 2
3030 810 2
3371 1563 1
3919 451 1
2383 1709 2
3831 1691 1
3018 1055 2
2762 328 4
3714 2569 1
444 2553 2
458 ...

output:

620
357
988
890
3516
1690
1449
303
1259
462
2043
3006
1866
792
11521
738
1814
933
2004
3667
1983
2486
4655
976
957
2473
775
514
3742
316
145074
2301556
38308
701585
128902
438274
39379
20056
60817
2594914
1301899
1588724
3078212
2104109
978120
763258
1683241
365433
4085082
34486
828306
1156781
11649...

result:

ok 276 lines

Test #15:

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

input:

13 296
8043 4170 1
5891 46 50
5809 1368 2
4887 7911 1
6035 6457 1
2953 3539 2
4104 607 6
5184 6772 1
4125 3406 2
3041 3930 1
6013 3784 1
6836 1486 1
6650 7295 1
3055 3481 2
5416 816 2
2663 3768 2
4166 7360 1
3608 3843 1
5711 7456 1
7824 2308 1
5109 132 18
5539 6456 1
6014 4917 1
7857 7459 1
722 4174...

output:

2029
138358
5592
1635
3558
1851
17269
3344
1751
702
3552
3758
463
3247
5206
6371
772
2951
1738
4004
42935
858
3552
4013
1114
1093
2903
3769
2460
4175
15073828
6739949
3628843
6742502
7197254
11727032
12287327
10961071
3451444
3468014
1274299
1468375
221279
7754952
1724777
555695
1839318
565831
89479...

result:

ok 296 lines

Test #16:

score: 0
Accepted
time: 23ms
memory: 3568kb

input:

14 297
6045 16104 1
13741 13527 1
13666 209 10
12305 1174 3
12448 5824 1
6803 7763 1
15590 7238 1
8068 9485 1
14588 10542 1
6 2681 3
10499 8725 1
9678 5958 2
2680 3115 2
10010 15419 1
5157 11358 1
4982 1780 3
11406 989 3
5143 8928 1
1590 7136 1
11299 7141 1
2990 1131 7
10913 10808 1
15726 13487 1
43...

output:

2804
7532
45497
11389
7208
5798
7994
3057
483
8175
6721
7260
7929
1649
5386
12298
14266
2691
2247
3460
30189
6825
8028
5621
6705
63755
49
31666
17044
5183
9088278
29271586
21926957
16049437
4097774
6723565
6628340
11459272
55357505
14933118
19425757
17315541
17747761
62723
53705271
4814873
9729996
2...

result:

ok 297 lines

Test #17:

score: 0
Accepted
time: 47ms
memory: 3728kb

input:

15 300
31349 1802 1
22259 22587 1
23462 22537 1
9448 7002 3
432 25131 2
8518 22188 1
10019 5168 2
3289 3395 7
29294 7961 1
26410 13056 1
20994 11608 2
6214 1102 25
30989 24532 1
29958 1183 1
21993 1614 3
5348 10132 3
17993 20118 1
22679 23406 1
28938 19903 1
29361 13516 1
15347 1745 9
3134 7927 3
13...

output:

16030
6879
14059
25485
9212
10322
16693
49619
15516
3698
29784
191394
3984
15682
19430
18334
12691
13863
15427
15533
73632
21552
18107
51329
13360
6607
24803
15579
52393
4796
20820162
11672856
30347711
56123777
35438582
101465446
184550113
126594342
63636501
518446
32137284
8990272
143355355
3793255...

result:

ok 300 lines

Test #18:

score: 0
Accepted
time: 124ms
memory: 3572kb

input:

16 300
33941 38966 1
4948 58924 1
14760 63396 1
61777 11565 1
7718 59747 1
21890 52999 1
43463 21733 2
18253 31482 2
14033 41634 1
36579 14551 1
38701 48483 1
14074 53430 1
31632 2657 6
26541 64425 1
43328 6610 2
39613 28491 1
28320 6421 1
4697 24666 1
51923 38690 1
33259 9737 2
34789 48429 1
9745 6...

output:

24870
17622
5018
31829
18315
5464
35421
39292
19894
25530
13030
310
123197
23021
56086
26288
5866
8779
29366
30222
25083
18821
6822
51467
29665
87441
28901
24192
27354
24542
229436129
221024210
220810561
795395977
255538006
66959184
84938837
477741039
381332494
737530682
324426576
25651882
98462624
...

result:

ok 300 lines

Test #19:

score: 0
Accepted
time: 167ms
memory: 10036kb

input:

17 300
84294 406 7
47966 52379 1
106009 77845 1
23688 27301 3
64980 65048 1
47846 44902 2
23076 7086 14
25190 53684 1
54084 5167 9
87872 40413 2
70678 59170 1
95628 41599 1
118169 16539 1
122765 105758 1
55995 105201 1
88856 21979 2
67259 110586 1
41040 70240 1
26650 124323 1
123344 15591 1
95569 86...

output:

304463
22380
14817
117204
12253
67138
494327
39067
412950
31420
50438
28338
15577
63461
46768
74223
3098
43029
9857
63605
56662
49819
5552
52720
65171
64819
29655
55570
16312
43458
682926411
2230313325
172730241
168775
3904272858
1868044259
2753815266
515462719
414563614
1844384430
9218269
846515865...

result:

ok 300 lines

Test #20:

score: 0
Accepted
time: 157ms
memory: 9784kb

input:

18 300
158138 210076 1
78004 6013 24
214197 108715 1
182671 131026 1
72042 252245 1
131188 187365 1
206159 228628 1
215326 113321 1
33293 184998 2
87027 105509 1
176124 1506 20
92587 46741 3
86841 260938 1
54462 148700 1
203860 220741 1
150110 89788 1
176066 1038 23
72944 216364 1
30149 216888 2
218...

output:

3283
1957823
59543
111205
83548
24583
117077
119368
129342
87295
1323783
200737
5452
79153
116502
51532
1832266
83774
75063
47650
45646
188674
45781
31762
117626
73681
113079
43377
85631
104249
9518625733
2076150356
12903945629
8053846165
3528140061
2043882865
228590234
6475166632
3328227717
6912303...

result:

ok 300 lines

Test #21:

score: 0
Accepted
time: 125ms
memory: 9892kb

input:

19 300
306751 496908 1
154228 426522 1
444732 54452 1
88453 289952 1
230399 84205 3
357334 32383 6
396725 490232 1
43637 161459 1
60732 159421 3
176341 448840 1
281554 231306 1
84343 385533 2
277277 289596 1
240224 378049 1
319424 67779 1
231115 425112 1
404630 281168 1
489842 324804 1
348403 385536...

output:

207761
169631
242256
153187
332907
892075
230255
141983
130345
175159
201462
286582
100196
191130
210930
94426
232231
126767
109087
1630303
56307
246712
60938
15644
227531
40804
518931
57956
1139035
69038
48472824158
13626509194
44353112368
8312678740
8220043133
62770978323
33344263900
5808761217
44...

result:

ok 300 lines

Test #22:

score: 0
Accepted
time: 18ms
memory: 12012kb

input:

20 300
345717 1044144 1
399471 298073 1
510558 311431 1
166203 901259 1
697928 625873 1
47771 932938 1
256730 998453 1
906619 831854 1
1036808 471697 1
535799 134186 3
919764 479903 1
783171 871181 1
748640 333166 1
695998 491176 1
1003727 140532 1
217291 180110 5
615783 428648 1
969249 286694 1
668...

output:

174287
181006
97446
9490
109156
274088
326329
488800
260673
264331
492086
457939
449306
218072
513077
1366386
104022
252228
429298
242226
360957
220738
314721
250952
432208
518979
267466
321968
956632
447972
2255848789
45876536700
851807652
62301067677
61681580603
188616552919
151795354889
132224913...

result:

ok 300 lines

Test #23:

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

input:

21 300
1373292 1781127 1
513254 248050 4
234299 160212 12
183648 1871174 2
1975618 1511321 1
1068614 388480 3
710433 1313083 1
1620343 6280 72
705077 777697 1
375695 138220 9
1347370 1507416 1
899467 2016573 1
870936 153724 2
1466087 333275 1
866896 207649 5
511953 1276262 1
255213 1982599 1
79875 1...

output:

867613
2625182
6432420
1608197
509096
1395354
350949
38731680
700559
5827806
861132
749157
482979
890812
3077296
326139
147023
136064
783444
340724
1263063
1834844
676198
276689
898354
4313150
433087
964771
1460300
2540616
226541326280
564646570044
94912476696
402864787287
60430814332
146395511727
1...

result:

ok 300 lines

Test #24:

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

input:

22 300
1814557 1987515 2
3700425 2063100 1
1933758 3774053 1
392808 2675035 2
823926 2826156 1
1280257 3176926 1
2836345 2656879 1
1863191 1912863 1
179696 2991120 1
1310259 1536044 1
1601638 3348553 1
1748027 2852629 1
1090008 590039 5
2607087 982846 1
431014 1806771 2
3197358 3084980 1
3023692 172...

output:

2001990
1973684
766008
1600665
313639
342160
1757664
94648
1093503
172017
724493
742792
6924551
1700351
490084
1847917
1804501
256526
328657
2136784
936033
39758907
1560199
1346264
1941469
572774
142982
451469
948769
1687891
244082510303
450948678087
2434084870121
3298709231960
2367255920630
2313641...

result:

ok 300 lines

Test #25:

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

input:

23 300
6804987 1586582 1
6762705 1402266 1
5493126 3389662 1
2817058 6738791 1
4923018 2537441 2
6305976 2126881 1
3960363 2755984 1
598070 3819312 3
5316203 5257533 1
4190620 2020405 1
6350364 436788 1
3774250 7198468 1
2219711 4302989 2
5973054 7120046 1
5844055 3653435 1
3836506 1570806 2
17849 5...

output:

1899200
3787830
867608
2801419
5626223
918411
1543622
3685939
3426205
3144810
3684744
3040717
6379911
3590417
444770
3252630
2004777
3036215
3904830
3321027
2851379
4241282
1233644
261243
2794759
4140877
3921821
3946132
929715
5694199
3745305038081
3104692571788
2356879563446
1484528619155
588119213...

result:

ok 300 lines

Test #26:

score: 0
Accepted
time: 19ms
memory: 9884kb

input:

24 300
10152812 3698422 1
9488903 4322077 2
997997 7126112 3
13846973 14837890 1
12360724 13834571 1
8238939 2537306 2
15115749 5685916 1
8193298 4421312 1
3492540 13071874 1
2770935 8773990 1
14869334 2149077 1
1492568 11637979 2
3493012 12635464 1
4694577 9705224 2
8429022 5288223 2
597347 1352716...

output:

6732510
10390056
18676002
7656049
3642243
7115087
1993310
6242631
5067441
76359
1977909
12044391
2533779
6581103
10774397
8206359
1081820
6399966
5624511
6342398
14075826
3374472
2150368
3914116
6676467
6584088
7730241
7898619
11699346
2662440
2407900399414
3344049467639
67223350601432
4689003397920...

result:

ok 300 lines

Test #27:

score: 0
Accepted
time: 28ms
memory: 10092kb

input:

25 300
23027263 31325428 1
10317501 12483065 2
9399550 21989935 1
3487806 24381431 2
15937399 18353740 1
25594969 6490304 1
4333808 24611446 1
26054981 2487907 3
21870684 28079927 1
26522430 11005301 1
15618682 477879 29
30367148 10795379 1
21736037 20194928 1
29588917 23682478 1
3858676 6065448 2
2...

output:

14145427
25056738
10738498
19986199
6186480
924209
2368015
38810830
6928140
7509608
267887744
15980398
1727827
986614
3886569
227947
68299912
11118252
17663502
30972826
15219441
15617598
28079244
11375520
15850435
128224242
5991803
11099183
1774956672
15593564
26582044479969
4257878064326
3342718520...

result:

ok 300 lines

Test #28:

score: 0
Accepted
time: 41ms
memory: 11812kb

input:

26 300
46411316 36477593 1
17156527 60819023 1
35243594 4557078 7
4225500 62288085 2
23084286 43483804 1
20818870 38517305 2
61505065 43650048 1
15449990 37581676 1
13709594 47254610 1
39694450 31695747 1
18495638 10998074 3
36660742 28154600 2
21659567 63398065 1
1421264 514704 89
5663271 23598861 ...

output:

14190023
21066350
113646876
51239208
11274144
42602230
32153485
20639717
20204616
13350415
53725951
19733326
11096055
1460853681
18193036
30967583
24906430
13948494
861102194
7785147
20910781
46752171
11700313
8087754
29602191
20947036
1370077
30231369
10767796
17955762
73170487130874
21215990349231...

result:

ok 300 lines

Test #29:

score: 0
Accepted
time: 42ms
memory: 9960kb

input:

27 300
8696064 55558660 2
97868515 125422785 1
68782837 39568376 1
47385262 21345504 5
7041984 26566918 1
61895765 99202082 1
133485066 128873804 1
56474427 9030298 2
94981092 7635665 1
47148438 32530938 3
123441727 41226938 1
120629846 4877728 2
43863924 73660500 1
10422421 121045761 1
96994583 128...

output:

24066488
58021564
6343767
249662571
35314931
3064273
8365712
72638350
57299708
113632841
64414866
16181610
695631
9040009
14450769
50461883
65644799
32130095
27831919
50602796
31326902
860000
198611197
223764563
50723166
31390436
66084635
58816814
19361664
73622980
853824463256036
1084769912525867
2...

result:

ok 300 lines

Test #30:

score: 0
Accepted
time: 84ms
memory: 9964kb

input:

28 300
96265437 121037205 1
235502848 98834703 1
157671009 113833715 1
76781443 149672592 2
41768975 241362381 1
217520485 50883386 2
114371479 32256822 5
135035238 262046459 1
5243357 175403671 1
8519695 165728362 2
170403136 261993799 1
131449294 229061194 1
242141158 118296719 1
171299712 1950781...

output:

91175227
125984578
26631654
29308704
38775555
255698820
511299868
12608459
34209852
179909668
27427412
99971191
127644157
109933795
55516217
90930526
53881364
47809668
122240281
7933988
118797502
73801617
120623269
128794490
107274985
65065318
130529142
123026414
28481606
107993526
2592783681910165
...

result:

ok 300 lines

Test #31:

score: 0
Accepted
time: 83ms
memory: 9940kb

input:

29 300
349088187 495816839 1
410005466 523068880 1
156264194 513236468 1
292867548 210456198 2
407780359 131842123 1
448601327 497212862 1
51821621 177871829 3
54573710 507686852 1
47564496 492195003 1
263676064 205714566 1
7665654 17931844 17
375699767 427937310 1
454422612 47330579 1
2780207 34019...

output:

55372444
236719097
173283779
272446784
29520352
123184031
432349304
147861158
73054427
50034186
1414265027
228142672
30977922
134912782
41725533
267323232
48004891
203304457
118609691
4068001440
1152014179
137569890
22791780
110594999
178442067
168654667
148952754
68617790
191188823
576064153
276775...

result:

ok 300 lines

Test #32:

score: 0
Accepted
time: 174ms
memory: 9928kb

input:

30 300
576952057 839596285 1
17929580 910665796 1
387861719 64075472 2
466615473 757075319 1
186239677 230576420 4
887353043 872595912 1
453187330 1045156224 1
154853132 923140966 1
521245036 424202259 2
660227493 376774986 2
228759656 953727042 1
167101645 971656613 1
176029737 285776511 1
90864087...

output:

206336736
136458926
556110767
192544664
1326366529
490273720
381732291
153574371
524946038
565413851
325625373
310210871
156221446
61949459
477664440
12236286
124732231
128944913
369359671
134459733
176802659
379754786
11410476
366534576
288767275
535058514
466669857
389113783
273907492
133296805
13...

result:

ok 300 lines

Test #33:

score: 0
Accepted
time: 901ms
memory: 3508kb

input:

30 300
7487 32618 32919
10593 32619 32918
2592 32620 32917
6362 32621 32916
20866 32622 32915
14376 32623 32914
14894 32624 32913
13645 32625 32912
13143 32626 32911
2756 32627 32910
4905 32628 32909
7284 32629 32908
2910 32630 32907
17560 32631 32906
15796 32632 32905
11699 32633 32904
16468 32634 ...

output:

8839104750320
8860254702631
8825781025070
8810825094022
8820942135405
8787665754761
9715019211235
8764245605245
8863029879145
8830692930390
8853693727283
8809329131379
8807652458810
8879265585037
8519070817132
8840786762497
8861770293529
8824548723208
8995801253486
8841165261966
8742534924318
871945...

result:

ok 300 lines