QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#249988#7620. Yet Another Subsequence Problemtime_interspaceAC ✓1ms3876kbC++202.6kb2023-11-12 19:12:122023-11-12 19:12:13

Judging History

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

  • [2023-11-12 19:12:13]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3876kb
  • [2023-11-12 19:12:12]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,j,k) for(int i = j;i <= k;++i)
#define ll long long
const int p = 998244353;
struct Matrix {
	int f[7][7];
}M0,M1;
const int N = 6;
ll A,B,G;
ll gcd(ll a,ll b){
	return b?gcd(b,a%b):a;
}
Matrix mul( Matrix a , Matrix b ) {
	Matrix c;
	rep(i,1,N) rep(j,1,N) {
		c.f[i][j] = 0;
		rep(k,1,N) 
			c.f[i][j] = ( c.f[i][j] + ( 1ll*a.f[i][k]*b.f[k][j]%p ) ) %p;
	}
	return c;
}
Matrix pow( Matrix a , ll b ) {
	Matrix res;
	rep(i,1,N) rep(j,1,N) res.f[i][j] = (i==j);
	while(b) {
		if(b&1) res = mul( res , a );
		a = mul( a , a );
		b >>= 1;
	}
	return res;
}
Matrix get() {
	Matrix a;
	int AA[7][7] = 
			{{0, 0, 0, 0, 0, 0, 0},
			{0, 1, 0, 0, 0, 0, 0},
			{0, 0, 0, 0, 0, 0, 0},
			{0, 0, 0, 0, 0, 0, 0},
			{0, 0, 0, 0, 0, 0, 0},
			{0, 1, 0, 0, 0, 0, 0},
			{0, 0, 0, 0, 0, 0, 0}};
	for(int i=1;i<=6;i++) for(int j=1;j<=6;j++) a.f[i][j] = AA[i][j];
	return a;
}
void solve(ll A,ll B,Matrix Ma,Matrix Mb) {
	// printf("*%lld %lld\n",A,B);
	// 	rep(i,1,N) {
	// 		rep(j,1,N)
	// 			printf("%d ",Ma.f[i][j]); printf("\n");
	// 	}
	// 	printf("\n");
	// 	rep(i,1,N) {
	// 		rep(j,1,N)
	// 			printf("%d ",Mb.f[i][j]); printf("\n");
	// 	}
	// 	printf("\n");


	if( B == 0 ) {
		Matrix zero = get();
		zero = mul( pow(Mb,G) , zero );
		printf("%d\n",((zero.f[1][1]+zero.f[3][1])%p+p)%p);
		return;
	}


	if( A <= B ) {
		solve( A , B%A , Ma , 
						mul( pow( Ma , B/A ) , Mb ) 
			);
	}
	else 
		solve( A - (A-1)/B*B , B , mul( pow( Mb , (A-1)/B ) , Ma ) 
								, Mb 
			);
}
#define g(a,i,j) a.f[i][j]
int main(){
	int T; scanf("%d",&T);
	while(T--) {
		scanf("%lld%lld",&A,&B);
		G = gcd(A,B);
		rep(i,1,N) rep(j,1,N) {
			M0.f[i][j] = 0;
			M1.f[i][j] = 0;
		}
		int AA[7][7] = {{0, 0, 0, 0, 0, 0, 0},
				{0, 2, -1, 1, 1, 0, 1},
				{0, 1, 0, 1, 0, 0, 0},
				{0, 0, 0, 0, 0, 0, 0},
				{0, 0, 0, 0, 0, 0, 0},
				{0, 0, 0, 0, 0, 1, 1},
				{0, 0, 0, 0, 0, 0, 0}};
		for(int i=1;i<=6;i++) for(int j=1;j<=6;j++) M0.f[i][j] = AA[i][j];
		int BB[7][7] = {{0, 0, 0, 0, 0, 0, 0},
				{0, 0, 0, 0, 0, 0, 0},
				{0, 0, 0, 0, 0, 0, 0},
				{0, 1, 1, 2, -1, 1, 0},
				{0, 1, 0, 1, 0, 0, 0},
				{0, 0, 0, 0, 0, 0, 0},
				{0, 0, 0, 0, 0, 1, 1}};
		for(int i=1;i<=6;i++) for(int j=1;j<=6;j++) M1.f[i][j] = BB[i][j];
		// rep(i,1,N) {
		// 	rep(j,1,N)
		// 		printf("%d ",M0.f[i][j]); printf("\n");
		// }
		// printf("\n");
		// rep(i,1,N) {
		// 	rep(j,1,N)
		// 		printf("%d ",M1.f[i][j]); printf("\n");
		// }
		// printf("\n");
		solve(A,B,M0,M1);
	}
	return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3852kb

input:

6
1 1
3 5
4 7
8 20
4 10
27 21

output:

4
70
264
196417
609
667131122

result:

ok 6 numbers

Test #2:

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

input:

18
5 9
23 30
820 483
5739 9232
86494 55350
606 13336
2768848 1124639
47995594 66053082
1069395 7177
7801842511 4390103762
47882886553 82678306054
193410894 6189355686
51594638 19992922190
59 110
422735115778072 658356435030265
9125338158530266 5328357177709583
60743352262021049 95595862538791630
629...

output:

988
220693002
133474535
202371605
778839228
282057418
935955056
943144752
409056617
627433544
578769776
917438628
24364208
109943645
352575425
68058533
402004723
894026897

result:

ok 18 numbers

Test #3:

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

input:

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

output:

986
264
4
4
7
781
264
264
4180

result:

ok 9 numbers

Test #4:

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

input:

7
10 10
9 5
5 9
5 8
7 4
5 9
4 8

output:

28656
1100
988
702
294
988
361

result:

ok 7 numbers

Test #5:

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

input:

10
4 7
5 9
9 5
5 9
7 4
9 9
3 10
7 4
9 5
6 4

output:

264
988
1100
988
294
10945
253
294
1100
207

result:

ok 10 numbers

Test #6:

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

input:

9
77 47
65 37
96 59
74 45
96 61
66 47
53 73
41 72
47 64

output:

477691493
223541570
510016172
616252466
634241188
463620644
498542012
162791920
984013116

result:

ok 9 numbers

Test #7:

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

input:

8
41 69
86 51
44 88
47 66
71 44
47 77
44 44
9 17

output:

856129900
783572707
168948980
519731719
796410895
739386210
133340520
191860

result:

ok 8 numbers

Test #8:

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

input:

9
47 73
99 15
52 73
29 52
82 53
49 78
71 40
50 87
84 53

output:

769345491
690191730
757588716
658697918
61904949
629708093
220994184
297434348
28621139

result:

ok 9 numbers

Test #9:

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

input:

7
661 462
386 656
797 510
19 2
685 406
994 984
86 165

output:

108717767
243878739
146514460
348
433968238
266547073
518079889

result:

ok 7 numbers

Test #10:

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

input:

7
640 391
187 37
185 77
758 530
690 708
614 422
745 596

output:

568664902
101789251
757511817
887691770
177453450
32893736
437096982

result:

ok 7 numbers

Test #11:

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

input:

8
813 469
744 999
637 437
394 303
773 773
380 643
38 9
703 426

output:

454035451
338288113
916487884
221556201
179854568
52657041
26618143
962558445

result:

ok 8 numbers

Test #12:

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

input:

8
6855 4213
4112 6914
5778 2583
4988 8449
8090 8090
6519 4733
4434 6958
2 3

output:

427280974
44013214
375314206
144262561
427379094
372013990
839270931
18

result:

ok 8 numbers

Test #13:

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

input:

8
8409 5416
8107 4913
95 98
115 3
5013 7048
9328 5735
1680 5712
5197 7557

output:

894035672
40190853
343168705
190160
390361879
183351154
606244444
134913462

result:

ok 8 numbers

Test #14:

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

input:

9
5182 8121
3750 6458
8234 8234
4143 7423
4020 1789
4107 7290
6723 3999
4268 6070
7780 3890

output:

866885729
688535194
823578849
212358139
362917931
67863647
455387876
758964821
193741943

result:

ok 9 numbers

Test #15:

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

input:

7
61155 95200
45410 29617
52271 72405
65732 48477
24291 69219
67575 35139
79612 44714

output:

568124700
703486037
744399547
157090122
340253631
764313623
405183638

result:

ok 7 numbers

Test #16:

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

input:

9
58285 95000
61322 43451
62444 98391
63929 37316
11880 85320
55132 89028
46015 74851
95036 57832
97346 57569

output:

198194769
642221077
706321582
889996800
236557792
438005278
854653054
551428347
412917166

result:

ok 9 numbers

Test #17:

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

input:

9
70070 51175
1 3
97696 89440
76449 76449
39928 68508
53907 53907
48569 83915
64151 44772
423 4

output:

386957046
8
333547672
669126229
622003028
967849140
694422542
68403374
399271894

result:

ok 9 numbers

Test #18:

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

input:

7
791062 495727
446934 701097
575527 973782
601232 973330
1293 33622
654288 790598
582881 422021

output:

787234183
89769894
656957068
144699935
985638
436404539
589184034

result:

ok 7 numbers

Test #19:

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

input:

9
170761 370325
835313 538289
557394 885834
4 1370
457105 725030
170133 373897
606675 954589
478770 675786
529800 529800

output:

938892037
351941869
451634146
177505605
507054806
847951838
454269997
734099694
483445163

result:

ok 9 numbers

Test #20:

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

input:

9
971470 571018
729856 522877
712674 782955
527307 855805
1991 6
646650 479073
664436 461056
543147 736991
1027 2

output:

701913251
360490926
401476354
140864080
439953424
58245462
571144790
226876232
795156

result:

ok 9 numbers

Test #21:

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

input:

7
4220475 7200014
8946114 5607972
9217056 5889071
216495 8018
9263205 6175470
9381418 5709506
1305186 5438275

output:

416147761
504552270
531404017
597473622
227696082
526572165
932407358

result:

ok 7 numbers

Test #22:

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

input:

8
4735393 5463915
50137 654914
2203 4
2925479 5850958
5159591 8973433
7313341 4117661
5899 8
9318992 5940830

output:

830746100
701627501
861951012
734922707
586974926
54838635
54717862
962062441

result:

ok 8 numbers

Test #23:

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

input:

8
4808286 7533233
5427286 7627443
7049100 4420557
8918768 5668723
674651 626518
4540185 161190
1410422 8462532
7049224 4534562

output:

228187053
202526633
99774240
904698472
480292240
855142423
37675392
981266426

result:

ok 8 numbers

Test #24:

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

input:

10
33704480 11375262
63375993 63375993
12 13
58407009 98800752
10 7
381848 5348452
88342222 50792883
55352977 76210207
361275 3998109
58416656 94841469

output:

649109810
36477705
289153
752071377
5394
292760513
85444308
575684169
613771553
675962623

result:

ok 10 numbers

Test #25:

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

input:

7
34852528 49858286
62481622 49765513
75583113 25194371
3229939 804483
58329210 93597303
23508450 62689200
5 8

output:

391402413
137652286
768999263
472921885
836021626
100793612
702

result:

ok 7 numbers

Test #26:

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

input:

8
57310378 88790898
13 9147
1549494 24595
8452791 2087427
21621 172979
73536914 41674942
10163116 31757473
55581659 88587394

output:

41887077
681921806
26003660
68330985
630056979
227526752
694974420
566287628

result:

ok 8 numbers

Test #27:

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

input:

10
698700042 449659396
17 13
43899392 51200357
895050714 895050714
643725501 382794307
458560944 776109451
567286349 962689176
149158675 24522207
440485810 690959859
652728768 598334704

output:

703577031
2520080
194426181
120762097
456471628
53917573
344514670
705330170
462968000
697259102

result:

ok 10 numbers

Test #28:

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

input:

9
172917712 875395917
897335234 563015871
745518604 471032145
745253836 526187524
745397239 521218138
618365020 879980990
2609837 36375280
100674 7248541
405784272 696239702

output:

26528974
235341182
719622291
725483715
162432807
573688992
359069671
123532858
850989940

result:

ok 9 numbers

Test #29:

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

input:

8
19 16
919871160 979626570
652248464 796017040
513535282 890441475
587071118 935031010
566303476 566303476
853646878 518444900
54282 6459567

output:

31270230
469453648
140433663
633373156
490180087
832298148
445105898
409991300

result:

ok 8 numbers

Test #30:

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

input:

10
6316442971 3717676023
5707194159 9738462445
24455 10613497
4573236121 6647697858
4262400710 7167730777
270056596 1125156154
4585295484 4280782059
2130266613 431444507
7969708160 2789397856
6217859616 4582712819

output:

41234471
962654143
239500287
741697872
114104471
165586759
197355975
854304368
867087760
128591444

result:

ok 10 numbers

Test #31:

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

input:

8
4579668169 6390539165
1041646110 571219849
30 251
9 9
4671515135 7856932100
263421185 13851483
8361459884 4180729942
5455444332 8540064262

output:

555952223
137938692
573810687
10945
282167728
941458093
592851385
879877624

result:

ok 8 numbers

Test #32:

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

input:

7
4885592557 6722279544
6698742570 1014720768
5505975848 9085332219
9195021843 5693284264
52988491 378489
8801634660 9771021260
349665 18

output:

246109181
474709504
729257738
320828184
298549274
81287162
154217944

result:

ok 7 numbers

Test #33:

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

input:

9
64432609580 38353880909
43807625765 59263947003
16320158182 19429679437
3847856792 274728700
553640 37
8879682145 2927369495
70346968232 41700514029
78758894183 44807115997
99602254960 34562248040

output:

964237626
724959622
537133394
209972620
263976854
512058860
262701845
742703578
438174844

result:

ok 9 numbers

Test #34:

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

input:

10
40119253121 66288164640
87505712174 51288074660
36048827526 64066054154
84252980684 54190876423
446147 25876536
782712637 196016118
35016479961 14221711055
39589874533 64576938855
50165886770 84481820121
36605810431 60492661182

output:

774798817
342376143
939918052
623589627
125781574
937656495
18553261
784387301
537170792
279832098

result:

ok 10 numbers

Test #35:

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

input:

9
42 40
9305645972 60486698818
64950411971 41558316739
11050148 265460532
58383838184 29191919092
94333382274 34262678535
47483707407 80698978968
87395094281 56380378602
23984822092 35077779619

output:

454830513
458761936
767782510
956566290
722459276
110904025
991606480
829618195
279144874

result:

ok 9 numbers

Test #36:

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

input:

9
781818031945 475948866708
914806537124 601935899892
752123782181 525298689728
635268595617 375679155313
686238431621 478304282979
971027462869 605128611953
336341016872 593492888684
588233640889 936771497917
500339021121 718878308977

output:

416541065
93850085
32575703
927476140
275854305
524817775
115843013
612101788
535274867

result:

ok 9 numbers

Test #37:

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

input:

10
8 18
432360698142 700098703686
731142155950 372514886160
782624421493 445035963546
628123403278 373498610938
983205526516 627208237664
200940478371 558110905836
898239160130 449119580065
942666344678 542710523805
1376288731 33033576253

output:

118497
764002054
697392180
940670421
70833149
514323255
247311517
34986622
571700178
783375859

result:

ok 10 numbers

Test #38:

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

input:

9
463465274957 803405678339
38 39
855122660445 570081773630
565818450403 956900498105
513488249872 938556306902
666312248900 292118350180
311702183821 113258251057
220618909658 104522149028
1795060337 37699752631

output:

698978987
540539945
202456189
653488242
428733485
136622482
213065878
954077526
775245985

result:

ok 9 numbers

Test #39:

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

input:

10
664415605784 78244547126
9379552519928 5883628925869
5542594105687 7672977178418
5178938460625 8730427811713
9973455090260 5841455591693
56 16
734079467418 855862349973
81114853384 2385556446
149237977189 4033376322
5449911732823 8549857410677

output:

80131507
963784310
187103659
334889378
172535468
739514608
650459522
521260897
290739918
73066424

result:

ok 10 numbers

Test #40:

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

input:

9
4447910179998 7097252627075
11399089176 330557089593
4963101702009 6793726551400
9979205795063 2021104971152
8479740266012 4867793261721
5327068 72
9239905637409 3079968545803
5184273848100 8876120459083
4837533534365 8691234741624

output:

124690384
411971946
3773843
405089576
443529567
637322508
781006103
829103982
660929697

result:

ok 9 numbers

Test #41:

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

input:

10
981637513297 2128588091470
4714283499093 7576728679499
7495055678038 7495055678038
8324310665462 4634084762443
5710689724566 9667653254620
4305789682432 370028800834
4093285674016 7134248902838
4493096814116 6169635573974
78 10
55424515696 9293998475773

output:

506907545
175724684
171366228
746665106
993105044
966210024
527864656
70007987
160324237
127232425

result:

ok 10 numbers

Test #42:

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

input:

10
88004137971000 91959380127000
74147231981246 74147231981246
39434756902483 61919587653594
93 111
44181560163067 77615449759899
82796371085733 47668478750195
8801626941360 2517933769615
53330889214706 53330889214706
6872395393805 4602050084977
24278311806726 7716362667254

output:

977270307
951456599
826623512
2716956
757672346
493402036
241574837
936696309
272341593
90420684

result:

ok 10 numbers

Test #43:

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

input:

8
83242392419334 48080013444098
60557700619416 47712127760752
57820551505863 92086606077309
9092143767558 15196561910087
2705177411814 13610421069535
71283624982920 64494708317880
117 10271169
53977647239742 91676524000459

output:

1403378
328258696
841064592
703406177
536145853
91621790
519284514
219786799

result:

ok 8 numbers

Test #44:

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

input:

9
39389615240500 69398774281131
72905550036336 40503083353520
19984637490744 55133565358987
43317040541741 29703946351399
7584546229545 29580701409037
70706903233184 17676725808296
42273197935142 74296418759049
38126570359084 67695095849554
36653327088976 79435973089152

output:

830555900
16837817
240174960
41408696
333831437
851450450
303679113
864417616
66107106

result:

ok 9 numbers

Test #45:

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

input:

10
379809845776040 87521399244044
438651055673092 602633375926797
304488978161392 435733420086439
390988132449818 627934429378498
620167443903906 620167443903906
634916243215561 373673239266171
860296562918704 548434445628832
887229473296772 374750355147012
852714718210047 504067355022314
6138666444...

output:

494725545
57499987
396878960
479604519
257643714
648034103
914472685
883871305
266811385
888604046

result:

ok 10 numbers

Test #46:

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

input:

7
470178883855020 770276128511483
540990885807603 736886350162357
894729244714352 523324079814330
707170196942262 494394608815844
66701980590 180275623
103065153255233 206130306510466
364016287617199 653998959536254

output:

554745842
419154174
499608916
606331369
865725799
935915163
901511310

result:

ok 7 numbers

Test #47:

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

input:

7
381987309708152 675552067008456
456848180019281 711058812075785
668756377240308 468530841380440
90583278 101
531087374826792 590097083140880
99400300 151
739189959164630 522004964125469

output:

612853842
868424710
803022893
735904331
219013483
663905630
340785460

result:

ok 7 numbers

Test #48:

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

input:

9
7278964640577131 5036038524182689
5035531063135477 8496714647795219
3504743347919327 908440116241519
4001761136302463 7108707873098478
5149128773287081 6960878819273718
2091457546116447 2772408864757968
4089418491669467 6882229257269958
7486935806713669 4249189240699508
4096171687987639 6528182391...

output:

159753087
823145506
415988363
321650474
845685709
370868935
530244877
481080936
486435045

result:

ok 9 numbers

Test #49:

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

input:

7
2981568349279052 5004729683287459
4710516817026196 6626670578994707
4420652801695349 6872117106725460
7913190870392468 4496531997279638
9408392358677399 5899957062193866
4845480860712968 8299164681657158
7176864078512575 4072685305091161

output:

513577770
874790062
693690725
856693027
144728819
636310511
858823486

result:

ok 7 numbers

Test #50:

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

input:

9
4609843367489973 6494849388585310
2662683783497 54141028044012
220 66
7978094550997632 465764726411120
4831845778179482 7704967672005717
1858824847081840 4600928427969440
4312532571180340 6699870146306909
7443819315244825 5148069685184036
3986650745730536 6924653723452418

output:

44527881
747989882
237394030
791480810
831466537
766671424
646474343
355291795
41195775

result:

ok 9 numbers

Test #51:

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

input:

10
74631988611653950 53175145961327164
39113496181147364 68783798144114737
98491424748008905 61839083206166778
22796886891413346 5789636071869432
15448770668179690 4484576920375217
68928032797478541 49047045827906431
64041954599445660 46696705316367757
69341190934830226 42014659757002891
135 2989033...

output:

812434737
452625441
246964248
143489794
764082574
812961125
441305635
761639412
73687805
175602050

result:

ok 10 numbers

Test #52:

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

input:

9
1860619861443977 5814190954668714
19148688346591948 3771789733219899
44982507955009338 91631034723167170
52005363420696535 90524088869172793
53657472882811901 91761921619759696
69226091147005337 69226091147005337
98083040180495760 32694346726831920
50388744715723106 68020766962294917
6711152089747...

output:

234381716
686944777
950767811
55468278
510496489
703607441
90191858
599482356
404342753

result:

ok 9 numbers

Test #53:

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

input:

8
84896632069432888 84896632069432888
47786253690874448 81846724266738367
51 311
13603527784538305 3331601869278349
50559850767795431 46163342005378437
85677907426591888 42838953713295944
96579975575545669 58726298062990702
157 206

output:

666279267
432152330
607419028
414765301
588312608
554053126
917706967
590495550

result:

ok 8 numbers

Test #54:

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

input:

10
15726548567341138 51095235389923804
423775743308062335 932306635277737137
369 195
236164566623548641 364821851120140572
234643903330305546 188203386170436204
653381702369609877 482753500599640357
435420851782343362 155681131813320662
897210644247422197 530992500016150476
718571782455602517 462176...

output:

540621337
50385551
191369362
772925846
473788152
507982557
426922137
981279928
52949238
66732324

result:

ok 10 numbers

Test #55:

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

input:

8
720196177480139001 960261569973518668
563773350230943132 892912432264063728
922418069031280380 922418069031280380
495 16208934030
11239790100 172
170018167870043828 115365387622762295
694390635921274643 401713963039835356
394423271132672246 700958138011726362

output:

755248091
179536092
711232439
825632889
202808306
451735892
423205785
143830548

result:

ok 8 numbers

Test #56:

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

input:

9
957708297856455900 559198252307722576
398143389593862338 630616095604539612
543298540816145108 932249475805872579
471714198907827019 772135645591304430
567925898317206525 398186303828144283
731348283443152697 537794271900611289
891419850006053161 527313479837391247
408598194994107944 6413445614173...

output:

827987814
291482335
563410446
56842844
844762867
650626206
149584084
43849985
519737738

result:

ok 9 numbers

Extra Test:

score: 0
Extra Test Passed