QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#86055#5370. 循环序列tricyzhkx100 ✓147ms3756kbC++141.1kb2023-03-09 11:10:512023-03-09 11:10:54

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-09 11:10:54]
  • 评测
  • 测评结果:100
  • 用时:147ms
  • 内存:3756kb
  • [2023-03-09 11:10:51]
  • 提交

answer

# include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
struct Fastmod
{
	int m;ull b;
	void init(int _m){m=_m;b=((lll)1<<64)/m;}
	int operator()(ll a)const
	{
		ll q=((lll)a*b)>>64;a-=q*m;
		return a>=m?a-m:a;
	}
}Mod;
int mod;
int add(int a,int b){return (a+=b)>=mod?a-mod:a;}
int mul(int a,int b){return Mod((ll)a*b);}
int power(int a,int b)
{
	int ans=1;
	for(;b;b>>=1,a=mul(a,a))
		if(b&1) ans=mul(ans,a);
	return ans;
}
int getG(int P)
{
	int phi=P-1,t=phi;
	vector<int> pr;
	for(int i=2;i*i<=t;i++)
		if(t%i==0)
		{
			pr.push_back(i);
			for(;t%i==0;t/=i);
		}
	if(t>1) pr.push_back(t);
	for(int g=1;;g++)
	{
		bool ok=1;
		for(int p:pr)
			if(power(g,phi/p)==1)
			{
				ok=0;
				break;
			}
		if(ok) return g;
	}
}
int main()
{
	int T,n,m,k,p;
	cin>>T;
	while(T--)
	{
		scanf("%d%d%d%d%d",&n,&m,&k,&p,&mod);Mod.init(mod);
		int g=getG(mod),wm=power(g,(mod-1)/n),x=power(wm,(p-m+n)%n),ans=0;
		for(int i=0,w=1,pw=1;i<n;w=mul(w,wm),pw=mul(pw,x),i++) ans=Mod(ans+(ll)power(w+1,k)*pw);
		printf("%d\n",mul(power(n,mod-2),ans));
	}
	return 0;
}

詳細信息

Subtask #1:

score: 10
Accepted

Test #1:

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

input:

500
2 1 964005947 1 9909313
2 1 58747697 1 9911851
2 2 356170177 2 9910577
2 2 691057762 1 9905473
2 2 970192721 1 9900101
2 2 646236405 1 9908881
2 1 654587362 2 9908389
2 1 474538670 1 9915751
2 2 825402884 1 9902897
2 1 803555975 2 9908051
2 1 235213848 1 9901189
2 1 166280477 1 9917849
2 1 88428...

output:

3538172
3400099
339105
8978752
5558272
2337165
1445148
3367069
8812191
5861744
9109193
2895430
4886902
8191936
5413909
334076
5544139
2202690
6903860
2988599
9748480
9081604
5029906
7260445
5304540
9079527
1878225
3228926
4416591
8499890
346127
4551300
7305103
3434087
5959737
7897706
7714387
1918434...

result:

ok 500 lines

Test #2:

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

input:

500
2 1 263429581 1 9909857
2 2 244423477 2 9907291
2 2 464298551 1 9904819
2 2 837723444 2 9912079
2 2 931093228 1 9909253
2 1 361490106 1 9914521
2 2 267051289 1 9902917
2 2 712790201 1 9916091
2 2 335113935 1 9908881
2 2 194464000 1 9911917
2 2 406537691 1 9908911
2 1 410971167 2 9900857
2 2 4186...

output:

8437044
4352212
2321039
1575470
4278215
6085573
3597048
2787420
126478
8974493
1757251
79814
7164029
4651608
9255941
4087602
7044584
6904427
4472154
5762146
3877935
3710243
8178812
3465671
7265410
9015024
4845884
4424930
1514768
8422315
8389967
4406233
931490
4675778
201576
3124869
4520263
4674208
6...

result:

ok 500 lines

Test #3:

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

input:

500
2 2 264410801 1 9903871
2 1 680686716 2 9909001
2 1 807415098 1 9911081
2 1 56703047 1 9911339
2 1 519053359 2 9905521
2 1 811035876 2 9913429
2 2 153131085 1 9901813
2 2 88000106 1 9904381
2 1 600509542 1 9902209
2 1 762689728 1 9910993
2 2 924357515 1 9918637
2 1 548683445 2 9918721
2 2 993577...

output:

1391051
6539679
1542631
3482420
2140998
4448018
7652267
1989392
9717643
1670130
9241894
201453
1834605
4864407
3915526
1080168
1862472
9780676
6636313
1713600
4709406
3005375
1304163
851884
2922329
5470909
879441
3555469
1040330
5245680
6172548
6915051
3484688
7244843
3820708
6072548
949572
1149881
...

result:

ok 500 lines

Test #4:

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

input:

500
2 2 698754800 2 9915907
2 2 6237427 1 9911677
2 2 825192399 2 9902593
2 2 186676607 1 9900529
2 2 51019438 2 9910157
2 1 288976983 2 9903557
2 1 245853524 1 9900283
2 1 278142683 1 9910627
2 2 558652689 2 9909901
2 2 863702027 1 9900529
2 2 377247769 2 9914767
2 1 544831138 1 9916981
2 2 4868531...

output:

9637872
1867611
1589735
8968457
8393675
5871107
586588
6522239
9521777
2523000
7631304
8511213
3552190
2324897
1728245
3826282
2350688
3689688
6889876
4484224
8398988
7808056
7463031
5311892
6262673
8680884
2910274
2941189
4163362
3411341
2872078
4859757
499114
1230265
297997
9460521
3710800
6680810...

result:

ok 500 lines

Test #5:

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

input:

500
2 2 795869570 1 9905221
2 2 115143014 1 9909901
2 2 516438990 1 9914539
2 1 526659304 2 9917129
2 2 259680922 2 9900101
2 2 425409454 1 9906161
2 1 612435652 2 9911821
2 2 503678252 2 9903493
2 2 799235520 1 9906349
2 2 18539563 1 9904393
2 1 697972350 1 9900091
2 2 947371581 1 9900391
2 1 19025...

output:

674834
2907303
2359308
5245097
211523
5084202
9519049
9160261
126437
7481609
6061762
6527047
7891804
3975289
9121749
454704
2363777
6709643
559254
7098031
8985484
9061345
4711557
4775650
8906579
7975871
2606190
4525900
5611987
4235888
7985150
1964613
3095920
422565
4854960
900392
379564
7049418
2628...

result:

ok 500 lines

Test #6:

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

input:

500
2 1 92664381 1 9913219
2 1 793448759 2 9912169
2 1 496990137 1 9907057
2 1 969130814 1 9903937
2 2 830975168 1 9902881
2 1 980971147 1 9902621
2 2 569396457 1 9918421
2 2 594576310 2 9913289
2 2 640677963 1 9900859
2 1 150891915 1 9917087
2 2 480990057 1 9906241
2 1 34508485 1 9915847
2 1 708602...

output:

1640220
3272855
6014975
8683866
6774986
3787577
4469967
7580243
5671616
2807184
1712179
3523151
8733118
4802826
7936127
8286102
6247402
7866988
3583305
995565
204713
5551189
3312485
4493382
8660692
1424334
1816036
2735284
5921344
2980984
8196275
9332710
5993574
1416049
1418321
2016541
2814591
372381...

result:

ok 500 lines

Test #7:

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

input:

500
2 2 851531316 1 9918637
2 2 500575279 2 9917051
2 2 187196343 1 9906401
2 2 134941645 2 9905221
2 2 809438468 1 9906349
2 2 531236132 1 9905113
2 1 494636976 1 9906751
2 2 261652559 2 9917521
2 2 34718345 1 9918091
2 2 152744804 1 9902593
2 2 682170984 1 9905491
2 2 677099108 2 9900773
2 2 72560...

output:

9523229
9153234
8367139
5944868
7602655
9817405
6818983
2595309
7221707
3058986
9362227
7411516
845054
2408857
7656565
7549614
4831176
5158193
6218056
9792498
6286930
6669300
2109842
7916656
9352588
4062119
5898782
757786
4628467
8197896
1715701
8495609
4410338
4178831
3140790
4578687
2180948
626871...

result:

ok 500 lines

Test #8:

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

input:

500
2 1 28565371 2 9911647
2 2 68812831 1 9918721
2 1 672956631 1 9904231
2 1 756895662 1 9906361
2 2 876382251 1 9912757
2 2 254652421 1 9907801
2 1 932117069 1 9904261
2 2 179598708 1 9900091
2 2 548151408 1 9905911
2 2 995540670 2 9909901
2 1 149226784 1 9909649
2 2 238788233 2 9900641
2 2 399415...

output:

6065184
8959373
8500607
4333764
5271731
2671421
987212
5244521
7697186
53931
9249773
7619364
6725325
9617467
9688230
9551992
2649028
7731816
6570944
6361303
2218207
639929
294170
4934512
9722472
834713
5733665
7352859
67412
511822
6528084
1956690
4086826
5022150
2752171
5022446
5188274
3938587
50626...

result:

ok 500 lines

Test #9:

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

input:

500
2 1 664158125 1 9900493
2 1 289696530 2 9911353
2 1 591793829 1 9915137
2 1 54788311 1 9901277
2 1 828030336 1 9900421
2 1 508390295 2 9918533
2 2 86212122 1 9903037
2 2 581898219 2 9902089
2 2 1570489 1 9908881
2 1 631720634 1 9909337
2 1 228937236 1 9900769
2 2 179446688 1 9907717
2 1 17612193...

output:

4709493
7357419
5421970
4161406
5880247
6472482
3116660
9579742
3196351
421795
2917889
4329089
1251170
9579427
4441744
5219485
588056
3584148
4526114
9011522
9658028
7772173
9732111
3290373
7238481
2846
1758138
7564019
3212586
3627591
4980980
2197565
6407415
9480281
2619307
8235219
7223534
135990
88...

result:

ok 500 lines

Test #10:

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

input:

500
2 1 261670084 2 9915313
2 2 295067395 2 9908089
2 2 28875132 1 9914629
2 2 940038874 1 9913957
2 1 148289778 2 9911327
2 2 74687356 2 9907057
2 1 847001650 1 9901981
2 1 773726268 2 9906781
2 2 581687168 1 9912671
2 1 26997698 1 9907069
2 1 527116651 2 9901561
2 1 848132290 1 9900949
2 2 4800034...

output:

3821731
3803969
668717
9912457
6309769
7999526
8255898
8058497
7446427
1626341
5979212
5098074
7671774
8499025
2297047
5781574
1726161
618672
9314518
3301953
3952584
82136
2322719
1403864
7755563
1178849
9398582
4600699
5361285
692858
4165688
7782234
8811133
918295
3272400
1550184
6241143
6380674
63...

result:

ok 500 lines

Subtask #2:

score: 20
Accepted

Dependency #1:

100%
Accepted

Test #11:

score: 20
Accepted
time: 4ms
memory: 3748kb

input:

500
16 2 364546541 1 9900113
16 13 662900262 10 9900113
13 10 26594557 3 9900047
19 15 944366609 5 9900179
13 5 344506272 11 9900047
8 4 182367730 1 9900113
9 8 52715749 9 9900091
20 16 180599796 2 9900101
20 19 299203560 17 9900101
20 16 219036976 15 9900101
13 10 7733182 3 9900047
18 13 777510055 ...

output:

3336093
9618830
5522128
8065451
2648472
4439491
1934669
4618285
9355963
7848716
3793250
8243333
8921985
506023
5510095
2583467
2775344
3295686
3806686
1089471
6628697
8960191
1560888
2655147
5683270
831619
9166430
2394669
702975
407503
2625439
3345136
6442882
866123
9670654
1748546
873061
6888018
40...

result:

ok 500 lines

Test #12:

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

input:

500
7 6 26047165 4 9900101
3 2 172930604 2 9900091
6 5 564769944 2 9900091
14 7 48755653 1 9900101
7 5 953959191 6 9900101
9 2 910732789 2 9900091
7 4 542486510 2 9900101
9 1 908650279 9 9900091
19 10 607934211 12 9900179
10 8 898366200 2 9900091
11 8 996804203 9 9900199
9 5 554417875 2 9900091
14 1...

output:

1157737
9286990
3380949
9311241
1950568
9061098
6880745
3242335
2809730
1021803
1376036
4979042
9583840
1161164
1426838
5508862
5023185
8228238
2846115
946122
7989977
7765168
9371949
4940766
1571516
9771477
4894859
133081
1782527
2452303
4582345
3433290
2357700
9239063
7409851
5453631
6261619
320577...

result:

ok 500 lines

Test #13:

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

input:

500
4 3 234282370 2 9900101
4 4 840140664 1 9900101
5 2 429405455 3 9900091
9 2 216541140 2 9900091
7 7 927781860 7 9900101
19 13 169973780 11 9900179
2 1 724684520 1 9900047
8 8 93335379 5 9900113
11 11 33739745 1 9900199
11 8 567877532 9 9900199
16 12 986900668 4 9900113
2 2 132646906 2 9900047
14...

output:

1118671
6669937
4586006
515150
1875129
9632370
987857
8192286
9435309
7662227
5609563
9232940
7882715
5960199
6486179
2362361
23711
3289137
6021235
3155567
3653339
7922264
1353629
5238271
1610166
4748389
5203067
2362285
1493416
3419079
5318420
5942424
5055221
2139204
8088623
22024
6749858
9074254
86...

result:

ok 500 lines

Test #14:

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

input:

500
17 12 701524924 3 9900427
14 7 467638033 6 9900101
9 3 969366670 6 9900091
13 9 366831013 4 9900047
9 4 961036536 7 9900091
2 1 308834973 1 9900047
9 3 146562910 3 9900091
15 3 866498392 10 9900091
8 4 325469014 3 9900113
15 11 787794511 10 9900091
4 4 813235169 4 9900101
14 4 923268419 12 99001...

output:

324350
5771553
5860582
5030152
3986104
3672261
2241734
4648154
7471900
8523019
4995929
2848268
1776320
8563553
314912
8413593
1282440
9194743
6546897
4992756
6243805
1776654
3207759
7949929
4961582
2397082
2201672
9098072
8279355
3379583
1383736
934392
1496913
1904144
1603035
2159211
1126754
4344447...

result:

ok 500 lines

Test #15:

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

input:

500
7 4 729099731 5 9900101
14 8 933901829 1 9900101
7 2 188522944 2 9900101
16 4 490097065 14 9900113
20 4 227773802 8 9900101
18 3 771694095 3 9900091
6 5 347413909 1 9900091
6 4 898444959 1 9900091
19 19 731046880 16 9900179
9 2 661095567 8 9900091
9 2 2976921 1 9900091
18 1 92510745 5 9900091
7 ...

output:

8149945
8163654
385190
9241580
8468169
9457770
8597794
892022
8263330
2473023
2493591
8822945
9278540
510312
5332159
4688915
9473274
754396
2113496
7467903
5221779
5847950
1216793
8198368
3314998
4303869
7835273
7776164
5538620
4574105
1994666
7734861
8100786
9683127
3474114
3144035
2497317
6403667
...

result:

ok 500 lines

Test #16:

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

input:

500
7 7 861695931 7 9900101
14 7 67851139 14 9900101
13 10 534372280 5 9900047
15 4 181605601 4 9900091
13 12 898541131 6 9900047
3 2 473932660 1 9900091
18 14 482589481 11 9900091
7 3 599898209 7 9900101
14 10 787745099 3 9900101
20 4 136521398 18 9900101
17 7 893509898 16 9900427
9 5 681978102 6 9...

output:

8753527
4305115
5689990
1200210
4257524
6409073
4641371
7676636
6060253
2396646
2193225
2743821
6899012
660574
115976
2840412
2009541
869496
6565251
6971948
5108106
1300081
3564604
6185900
4023997
8311675
8654916
4444674
3619787
5901429
5541759
2987738
5526187
3304534
487841
3814166
434971
7480761
8...

result:

ok 500 lines

Test #17:

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

input:

500
6 3 482698257 5 9900091
2 1 616825767 2 9900047
8 6 584011287 8 9900113
9 8 408519194 1 9900091
4 3 475609363 4 9900101
4 1 741638359 1 9900101
13 10 460530046 4 9900047
6 1 692577462 2 9900091
15 13 526663228 2 9900091
17 1 534884472 11 9900427
11 5 946443614 9 9900199
5 3 789970665 2 9900091
8...

output:

7452103
5737009
2533342
8077315
2045492
3698978
1895163
2709576
8375642
6447348
9642827
2772223
5930707
4175132
8396105
7869659
5287474
1404137
6750697
9268138
441002
9895243
2396804
7860129
2832070
1518352
6165765
2020114
6286396
6311003
2998598
2993089
9573593
8336867
2265660
4990533
8635733
56756...

result:

ok 500 lines

Test #18:

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

input:

500
15 3 931756083 5 9900091
8 8 399812036 3 9900113
13 7 15821296 4 9900047
6 2 111006580 6 9900091
4 4 344212152 4 9900101
16 12 781631247 3 9900113
9 5 363289168 5 9900091
3 2 103032905 2 9900091
5 3 552215410 2 9900091
3 3 943466709 2 9900091
14 1 280627290 8 9900101
5 3 124408496 4 9900091
13 7...

output:

7515052
3346160
9403654
6333790
6705390
2492792
6469882
1899186
1988146
8155722
9213235
9179215
7264332
591242
8243477
2494550
6501118
4573494
7997462
7266981
5044190
7679095
4242821
5050912
4609452
4628728
142150
9432224
6443010
2114187
867989
1670613
1882980
1716466
155535
3532315
8061117
5737843
...

result:

ok 500 lines

Test #19:

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

input:

500
16 9 380995001 9 9900113
18 13 814223304 10 9900091
8 3 368498973 2 9900113
20 19 157208418 7 9900101
15 3 352013438 8 9900091
18 15 865396686 15 9900091
13 9 588431709 2 9900047
16 16 763710372 16 9900113
20 2 57563505 15 9900101
15 2 210489905 1 9900091
6 6 522680699 2 9900091
15 3 494715687 1...

output:

9177204
8317875
5725722
2012668
3947881
8819423
9777304
491895
6961557
2826314
8358153
9427798
6152249
7612845
6037546
7063868
5470753
1274425
5108856
5390833
8497496
9350805
5543967
4879019
8992192
6153152
963229
1234406
7394210
4330337
6762715
3325324
3643720
8963340
7138858
719346
6345459
5072063...

result:

ok 500 lines

Test #20:

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

input:

500
14 7 946528323 14 9900101
10 5 392277035 8 9900091
11 8 186213015 6 9900199
9 6 991128380 3 9900091
4 4 38037148 2 9900101
18 12 46298990 13 9900091
4 4 649068313 1 9900101
10 7 445632070 10 9900091
15 13 46265227 12 9900091
14 11 380746485 11 9900101
11 5 861612433 3 9900199
9 3 20549749 9 9900...

output:

4958511
4930924
6052892
1918262
6878920
7785048
287008
127166
3095795
5688264
7619170
2418747
4040056
2625662
7026586
9070301
6585081
9199096
7733396
1591321
695094
346736
4964909
7375916
294737
1129117
2418236
7414264
9790552
1465574
5060993
2026623
6209923
6318416
7631483
8707300
4033584
4242408
2...

result:

ok 500 lines

Subtask #3:

score: 20
Accepted

Test #21:

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

input:

12
1 1 566039 1 9914951
2 1 779314 1 9914951
5 3 644930 4 9914951
10 1 658830 10 9914951
25 12 572446 18 9914951
50 25 531616 31 9914951
59 29 678860 21 9914951
118 5 795057 37 9914951
295 193 536183 6 9914951
590 29 797193 307 9914951
1475 411 519342 228 9914951
2950 1177 705801 2035 9914951

output:

667914
1511733
1300626
649518
5382514
8807825
407266
3463100
8206767
3276649
1642122
5378529

result:

ok 12 lines

Test #22:

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

input:

32
1 1 955632 1 9916297
2 2 627787 2 9916297
3 3 710661 3 9916297
4 4 546497 3 9916297
6 5 983271 3 9916297
8 6 588459 3 9916297
12 2 835548 6 9916297
13 4 933844 11 9916297
24 6 999448 5 9916297
26 14 792916 9 9916297
37 9 584959 25 9916297
39 17 728278 36 9916297
52 42 546558 2 9916297
74 61 58642...

output:

7611975
1993552
8931460
4157850
319124
3574334
307138
754165
4326095
692324
8297801
6260353
5711677
4583416
4512912
1589160
5845526
755320
54972
6279033
8348093
2068851
5569733
9171169
9270914
6854639
9538599
39614
4660324
4963458
4469041
4217219

result:

ok 32 lines

Test #23:

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

input:

28
1 1 609119 1 9908033
2 2 781088 1 9908033
4 2 983177 4 9908033
8 5 816533 2 9908033
16 7 644720 8 9908033
23 19 968553 10 9908033
32 21 978910 4 9908033
46 40 836126 24 9908033
53 13 905113 16 9908033
64 26 697223 38 9908033
92 54 859718 15 9908033
106 74 744212 53 9908033
127 26 911046 121 99080...

output:

6346224
2337104
7153098
6549528
1577669
2557853
1386469
5254054
1787117
3135756
339355
6286012
4410701
533485
3802956
8130831
9760761
6100185
3985269
1835578
8113739
7638251
2167189
8593931
9677144
687279
1684051
1154914

result:

ok 28 lines

Test #24:

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

input:

36
1 1 756487 1 9910909
2 2 585649 2 9910909
3 1 647104 1 9910909
4 3 711172 3 9910909
6 5 569358 6 9910909
7 5 669681 1 9910909
9 9 883518 9 9910909
12 11 949377 6 9910909
14 12 532837 7 9910909
18 1 807222 4 9910909
21 20 671683 3 9910909
28 14 944378 27 9910909
36 32 914289 20 9910909
42 32 89995...

output:

737682
1306938
3519959
6199491
1064598
5915182
1611543
2141337
7551743
7220339
3002385
8659457
2126156
307268
6468876
9251566
5083610
3676552
8634896
1417767
6646112
9141859
8927784
1269941
4410775
7405718
2145223
7173944
6894170
1841006
1491026
9649002
1107300
1922338
4244085
8713104

result:

ok 36 lines

Test #25:

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

input:

24
1 1 863132 1 9909551
2 1 970742 2 9909551
5 4 777404 2 9909551
7 5 562936 2 9909551
10 3 939882 2 9909551
14 12 744646 8 9909551
23 17 548457 12 9909551
25 9 775067 22 9909551
35 21 577889 1 9909551
46 4 865789 13 9909551
50 3 558796 6 9909551
70 8 523365 9 9909551
115 99 668375 77 9909551
161 18...

output:

7790924
7398859
8824226
7066597
4855153
4248735
5307328
5621830
2603075
6733371
7029706
7335647
3847830
9661079
5074543
7368109
4143253
9634267
1428062
9814513
8940660
8638750
6730681
8468219

result:

ok 24 lines

Test #26:

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

input:

20
1 1 765967 1 9906737
2 2 506253 1 9906737
4 4 720158 2 9906737
7 5 600754 5 9906737
8 1 594239 2 9906737
14 1 865061 14 9906737
16 12 741306 4 9906737
28 5 698269 5 9906737
56 17 748929 1 9906737
112 111 853088 71 9906737
197 185 950415 24 9906737
394 206 582496 227 9906737
449 316 789297 435 990...

output:

7707569
1864524
7401009
4092480
7202281
1632659
2331626
8102917
1605803
3456221
6544378
195810
6132630
9411760
2261239
9548848
176696
6817013
8368029
8714495

result:

ok 20 lines

Test #27:

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

input:

24
1 1 980526 1 9902797
2 2 802071 1 9902797
3 2 678688 2 9902797
4 4 695131 2 9902797
6 5 558916 3 9902797
12 12 601406 2 9902797
59 16 951711 54 9902797
71 25 900511 1 9902797
118 101 710349 112 9902797
142 84 906345 42 9902797
177 23 931944 176 9902797
197 126 670344 189 9902797
213 31 513652 23 ...

output:

5591387
1640665
3533252
8867665
1114846
8322565
6896235
9092382
5467527
3039226
7771050
4576451
6926140
6330295
5820260
9559019
9251112
3955165
9547910
7240908
3086826
8146335
22758
8818844

result:

ok 24 lines

Test #28:

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

input:

16
1 1 835040 1 9917279
2 2 892060 2 9917279
7 6 751199 7 9917279
14 13 708589 4 9917279
19 15 961367 11 9917279
23 7 559628 18 9917279
38 28 888240 30 9917279
46 5 831688 27 9917279
133 26 583544 42 9917279
161 36 570723 161 9917279
266 262 589560 114 9917279
322 133 768222 18 9917279
437 238 62936...

output:

9155340
1676226
5779372
2389951
8678962
2001549
3991090
3826548
8107592
1206661
9186706
5153741
3240181
4388883
6576350
266682

result:

ok 16 lines

Test #29:

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

input:

56
1 1 605522 1 9909313
2 1 837048 1 9909313
3 1 816307 2 9909313
4 4 806249 4 9909313
6 4 937599 6 9909313
7 3 956138 3 9909313
8 1 522218 6 9909313
12 11 825827 7 9909313
14 10 624804 9 9909313
16 6 664790 8 9909313
21 15 579018 16 9909313
24 7 789133 5 9909313
28 17 661168 23 9909313
32 17 848288...

output:

7857025
9570592
9355031
8949748
6122202
2202677
1377171
903399
7408357
587533
4137250
397185
67366
4359967
8818061
8216844
9867910
6782875
8396798
6167451
7468762
2820132
6952863
1939165
9003907
3784231
6426299
46783
8103523
988042
3093442
1648690
6808562
1972290
371432
8387642
6159266
1975436
76259...

result:

ok 56 lines

Test #30:

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

input:

40
1 1 677635 1 9909703
2 2 681305 2 9909703
3 2 933838 3 9909703
6 5 937228 1 9909703
9 3 937809 3 9909703
11 8 846752 9 9909703
18 8 663201 5 9909703
22 6 879286 16 9909703
27 26 526752 9 9909703
33 32 648304 10 9909703
54 13 697526 28 9909703
66 17 542244 42 9909703
67 29 904013 62 9909703
81 21 ...

output:

9728535
7981612
4896281
8825510
6533465
2812872
5736833
2714844
2363734
5529301
5199098
3209285
4969417
3121259
9421662
7023493
4130647
3011716
4342213
4097519
7310513
6425545
9391729
1536656
2624789
8388568
1559069
8034660
7946740
444035
3422785
5507296
6971230
2865178
9906564
1089530
5418772
63774...

result:

ok 40 lines

Subtask #4:

score: 50
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Test #31:

score: 50
Accepted
time: 143ms
memory: 3552kb

input:

328
97218 91095 349624179 85709 9916237
85427 82189 48654321 46491 9909533
83288 26603 210601653 25848 9911273
99112 54093 178609392 93447 9911201
99049 46376 915922408 848 9904901
84654 2249 156373630 6920 9904519
87620 33268 595043688 51844 9901061
1443 408 658075412 473 9901867
549 233 96750575 4...

output:

6622914
2729786
1004989
9141178
4080152
91842
1326003
9613088
8765033
8060724
9269301
8298883
9278799
7583459
5441230
7653175
8826781
2203653
4529763
1433761
2136856
5381817
8854160
3246225
41800
6869357
3538679
7222948
702175
5488306
3860704
3396421
9631532
2657867
1840186
2339400
3574753
1016832
4...

result:

ok 328 lines

Test #32:

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

input:

378
85442 64386 426673157 85218 9911273
99124 62324 498597039 59751 9912401
86903 49423 113371057 20126 9906943
80530 57706 923021833 41553 9905191
69342 1093 95579596 16786 9915907
98090 25873 923867617 97542 9907091
75005 42610 882446086 19831 9900661
948 200 430044973 853 9905653
1209 981 6191828...

output:

4906572
495984
2132735
5957884
1858333
6208178
2459838
8721983
7091759
6353333
7090977
1931956
8037289
4959983
8492984
9338431
9782020
7530607
3155654
2101928
51160
3245701
1808335
8796175
2474432
4496586
3228546
1568083
8836037
4064837
7657430
416033
9691229
1416053
6112255
8202960
7557947
4208554
...

result:

ok 378 lines

Test #33:

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

input:

370
97135 12968 171423741 22574 9907771
86977 68676 527072328 47401 9915379
67895 40250 200067043 11511 9912671
86124 43610 444557500 40724 9904261
81219 78727 932572918 75354 9908719
74007 48571 369721433 32991 9916939
71814 38202 38248660 26749 9910333
1323 685 217337355 1149 9911917
616 228 45997...

output:

9596373
1951365
4303704
2843666
4691075
3406129
831780
813102
9829667
511350
4432242
3592694
4832393
4815858
9551431
2290109
4675646
1032802
8762249
8503053
2952118
4670590
2583149
3663823
3653781
5557643
8754367
1812773
5126723
4667942
302646
8221844
8475046
7245954
2290102
7028582
8661173
2025087
...

result:

ok 370 lines

Test #34:

score: 0
Accepted
time: 145ms
memory: 3680kb

input:

358
92534 22701 296033595 91149 9901139
81918 69755 225794222 25827 9912079
92574 91254 784649398 4970 9905419
76251 69196 55009239 37630 9912631
86947 7743 958677325 64110 9911959
81215 76673 199510990 48482 9908231
90912 59481 960962939 46553 9909409
1206 1034 643585057 290 9907291
1708 1544 92860...

output:

4565690
1976192
9003793
4663800
2680558
7223934
1081029
8652374
3196770
3845154
2907039
5751774
4922689
1813344
3194411
1880158
4950288
7642751
7135306
2025161
2451085
1875420
7444945
3090679
8691572
1686628
7155575
6516604
8140101
2230392
7254657
6535883
3244414
701913
2248853
7187359
4787275
24286...

result:

ok 358 lines

Test #35:

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

input:

328
97066 25202 336048681 34967 9900733
99048 98105 731574634 32846 9904801
95367 74742 813476268 86213 9918169
95220 58214 150258879 64675 9902881
67881 62644 635120004 64445 9910627
97134 32035 855174165 24650 9907669
81189 63928 769204756 42174 9905059
1674 1050 752738286 1342 9905059
99 18 52494...

output:

1166426
5983580
2271816
7423351
8208613
4276483
5668310
6854244
2564421
9708049
5100303
6621350
4684286
4886681
8444342
2764491
7774768
8029504
2771927
7075182
6547641
5829254
6940019
6682625
6489228
3753856
573771
2540822
6484808
1817731
1633283
9570077
3030898
5681954
7501344
9477451
560120
633685...

result:

ok 328 lines

Test #36:

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

input:

407
80586 3099 10138905 1355 9912079
66078 31377 19183363 56992 9911701
81284 78880 789358589 1497 9916649
79947 15082 361231280 61333 9913429
79852 46383 144620590 41816 9901649
90086 48035 487198899 1296 9909461
93523 91214 663734684 84936 9913439
1518 104 691559406 69 9911023
1848 1105 561554171 ...

output:

9229352
682619
4572027
9464043
4716199
3543658
8978133
7135758
2479707
3435035
9425325
8470757
7570651
1136416
7119642
5719676
7123948
2247729
4774637
1212998
4617189
1248100
1463143
5141048
8507454
492995
2026799
5326742
634008
7748800
2151122
6494463
8499488
9590970
2071137
8601803
5192997
3817101...

result:

ok 407 lines

Test #37:

score: 0
Accepted
time: 142ms
memory: 3556kb

input:

361
95252 52707 261321721 72706 9906209
94456 42594 821097997 68604 9917881
90912 79719 432116108 29314 9909409
85470 84842 11464585 4504 9914521
76240 42985 333727290 37942 9911201
79840 50616 212146058 68593 9900161
98132 91915 293188611 64306 9911333
2187 331 779457504 1522 9915859
642 235 225094...

output:

3538194
9690462
7681749
3169921
1452584
8596647
6796733
4435868
1780643
5101213
262790
5496605
190856
1882875
8201136
7879468
9407639
7195309
4894974
8222614
2288372
8203690
5673241
411319
4111902
9849127
5662346
8863949
9156739
3710571
8007590
9062556
3380371
2129891
9063144
729853
2798237
8219838
...

result:

ok 361 lines

Test #38:

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

input:

346
98162 62337 780405970 85885 9914363
97063 5504 791816718 71897 9900427
90840 81727 789745205 79341 9901561
91715 43546 487772695 57464 9905221
93543 2042 798694176 27497 9915559
97205 63086 750986755 27714 9914911
72835 48938 938019191 29098 9905561
1107 708 949781376 434 9901009
437 280 8673059...

output:

6132615
4249544
9524275
4807337
3900054
2113735
4122837
4001642
1980154
3783362
7561651
9289685
8340922
3527585
6957289
4305889
2613669
3184532
9109926
4694151
777760
1522846
1275761
1951715
3055038
5884238
3282250
5921283
3974213
2622462
6975556
7763594
843760
564690
4500989
915541
5609381
5651113
...

result:

ok 346 lines

Test #39:

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

input:

419
66979 40088 699771730 22301 9912893
99124 36579 170946660 61339 9912401
72840 34472 289557090 41034 9906241
93423 45386 371222507 20283 9902839
77426 39507 975167353 68319 9910529
75138 46929 365410576 10604 9918217
81900 80713 78890900 4702 9909901
164 142 980851829 162 9901009
2346 2206 744238...

output:

5483456
9579877
3577451
3555154
6084182
5543872
5006133
5126257
4863833
7545037
6926565
3023904
6541552
3511302
3801072
1109757
6077878
7744256
7991153
6991068
1057051
7773080
8818292
7434
3376213
2847567
8632875
7208093
3301640
2713634
3063673
6574266
8644227
93943
7418829
8079282
736703
2033867
96...

result:

ok 419 lines

Test #40:

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

input:

454
71770 4376 521906972 25901 9904261
88471 61720 929304238 75717 9908753
72835 12455 543093727 5799 9905561
72320 58459 387741943 68652 9907841
83935 16074 678783750 36395 9904331
82513 47473 158223043 34466 9901561
78588 38382 290803034 18598 9902089
386 115 832982920 257 9902831
553 553 10176363...

output:

901261
5113405
1872240
7188865
58331
5501596
1370100
9519886
1388418
5968946
539983
7697906
570664
1912722
8593189
3786529
2297990
9882327
3425333
4480333
3512361
6246900
7697517
6794192
9315104
2125086
937845
5083245
1569235
1832513
3980973
8901359
784787
4245952
5792599
6665387
2931584
7963973
233...

result:

ok 454 lines