QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#931243#4554. 联通子树玩原神的都进队了 (Junlin Ye, Ruichen Dai, Chenghan Li)5 1779ms244352kbC++144.4kb2025-03-10 21:51:202025-03-10 21:51:21

Judging History

This is the latest submission verdict.

  • [2025-03-10 21:51:21]
  • Judged
  • Verdict: 5
  • Time: 1779ms
  • Memory: 244352kb
  • [2025-03-10 21:51:20]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MP make_pair
mt19937 rnd(time(0));
const int MAXN=1e5+5;
const int MOD=1e9+7;
int n,q,c[MAXN],in[MAXN],out[MAXN],stk[MAXN],top;
int x,y,z,nx,ny,nz,tot,sx[MAXN],sy[MAXN],sz[MAXN];
vector<int> edg[MAXN],vec[MAXN],son[MAXN],ver;
int ff[20][MAXN],dep[MAXN];
ll f[MAXN],sf[20][MAXN],sg[20][MAXN],sh[20][MAXN];
ll dp[MAXN][6][6][6],tdp[6][6][6],ans;
// f: 必须全取,g 自下而上不全取,sh 自上而下不全取
ll ksm(ll a,int b){ll r=1;while(b){if(b&1)r=r*a%MOD;a=a*a%MOD,b>>=1;}return r;}
void dfs(int u,int fa){
	ff[0][u]=fa;f[u]=1;in[u]=++tot;dep[u]=dep[fa]+1;
	for(int v:edg[u]) if(v!=fa) dfs(v,u),f[u]=f[u]*(f[v]+1)%MOD;
	for(int v:edg[u]) if(v!=fa) sf[0][v]=f[u]*ksm(f[v]+1,MOD-2)%MOD;
	sg[0][u]=sh[0][u]=1;out[u]=tot;
}
inline int lca(int x,int y){
	if(dep[x]<dep[y]) swap(x,y);
	for(int i=19;i>=0;i--) if((dep[x]-dep[y])>>i&1) x=ff[i][x];
	if(x==y) return x;
	for(int i=19;i>=0;i--) if(ff[i][x]!=ff[i][y]) x=ff[i][x],y=ff[i][y];
	return ff[0][x];
}
inline int anc(int x,int y){
	// x -> y 最后一个点
	for(int i=19;i>=0;i--) if((dep[x]-dep[y]-1)>>i&1) x=ff[i][x];
	return x;
}
inline ll ttf(int x,int y){
	// x -> y 不能触碰 x,必须包含 y
	ll ans=1;
	for(int i=19;i>=0;i--) if((dep[x]-dep[y]-1)>>i&1){
		ans=(ans*sf[i][x]+sh[i][x]);x=ff[i][x];
	}
	return ans;
}
inline ll ddf(int x,int y){
	// x -> y 不能触碰 y,必须包含 x(忽略 x 子树内)
	if(y==ff[0][x]) return 1;
	ll ans=1,co=1;x=ff[0][x];
	for(int i=19;i>=0;i--) if((dep[x]-dep[y]-1)>>i&1){
		ans+=co*sg[i][x]%MOD;co=co*sf[i][x];x=ff[i][x];
	}
	return ans%MOD;
}
inline ll fff(int x,int y){
	// x -> y 不能触碰 y,必须包含 x
	ll co=1;
	for(int i=19;i>=0;i--) if((dep[x]-dep[y]-1)>>i&1){
		co=co*sf[i][x];x=ff[i][x];
	}
	return co%MOD;
}
void lk(int x,int y){
	// cerr<<"Edge: "<<x<<" ---> "<<y<<endl;
	son[x].push_back(y);
}
void dfs1(int u,int fa){
	memset(dp[u],0,sizeof(dp[u]));
	dp[u][sx[u]=(c[u]==x)][sy[u]=(c[u]==y)][sz[u]=(c[u]==z)]=1;
	ll cf=f[u];
	for(int v:son[u]){
		dfs1(v,u);
		cf=cf*ksm(f[anc(v,u)],MOD-2)%MOD;
		memset(tdp,0,sizeof(tdp));
		// 不选
		ll co=ttf(v,u);
		// cerr<<"("<<v<<","<<u<<"]: "<<co<<'\n';
		for(int x1=0;x1<=sx[u];x1++) for(int y1=0;y1<=sy[u];y1++) for(int z1=0;z1<=sz[u];z1++) 
			tdp[x1][y1][z1]=dp[u][x1][y1][z1]*co%MOD;
		co=fff(v,u);
		// cerr<<"["<<v<<","<<u<<"]: "<<co<<'\n';
		for(int x1=0;x1<=sx[u];x1++) for(int y1=0;y1<=sy[u];y1++) for(int z1=0;z1<=sz[u];z1++) 
		for(int x2=0;x2<=sx[v]&&x1+x2<=nx;x2++) for(int y2=0;y2<=sy[v]&&y1+y2<=ny;y2++) for(int z2=0;z2<=sz[v]&&z1+z2<=nz;z2++) 
			(tdp[x1+x2][y1+y2][z1+z2]+=co*dp[u][x1][y1][z1]%MOD*dp[v][x2][y2][z2])%=MOD;
		sx[u]=min(nx,sx[u]+sx[v]);sy[u]=min(ny,sy[u]+sy[v]);sz[u]=min(nz,sz[u]+sz[v]);
		memcpy(dp[u],tdp,sizeof(tdp));
	}
	if(dp[u][nx][ny][nz]){
		// cerr<<"["<<u<<","<<fa<<"): "<<ddf(u,fa)<<'\n';
		ans+=dp[u][nx][ny][nz]*ddf(u,fa)%MOD;
	}
}
int main(){
	// freopen("Otomachi_Una.in","r",stdin);
	// freopen("Otomachi_Una.out","w",stdout);
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin>>n>>q;
	for(int i=1;i<=n;i++) cin>>c[i],vec[c[i]].push_back(i);
	for(int i=1;i<n;i++){
		int u,v;cin>>u>>v;
		edg[u].push_back(v);
		edg[v].push_back(u);
	}
	dfs(1,0);
	// for(int i=1;i<=n;i++) cerr<<sf[0][i]<<" \n"[i==n];
	for(int i=1;i<20;i++) for(int j=1;j<=n;j++){
		ff[i][j]=ff[i-1][ff[i-1][j]];
		sf[i][j]=sf[i-1][j]*sf[i-1][ff[i-1][j]]%MOD;
		sg[i][j]=(sg[i-1][j]+sf[i-1][j]*sg[i-1][ff[i-1][j]])%MOD;
		sh[i][j]=(sh[i-1][j]*sf[i-1][ff[i-1][j]]+sh[i-1][ff[i-1][j]])%MOD;
	}
	while(q--){
		// cerr<<"New query "<<'\n';
		cin>>x>>nx>>y>>ny>>z>>nz;
		ver.clear();
		for(int o:{x,y,z}) for(int u:vec[o]) ver.push_back(u);
		sort(ver.begin(),ver.end(),[&](int x,int y){return in[x]<in[y];});
		int k=ver.size();
		for(int i=0;i+1<k;i++) ver.push_back(lca(ver[i],ver[i+1]));
		sort(ver.begin(),ver.end());
		ver.erase(unique(ver.begin(),ver.end()),ver.end());
		sort(ver.begin(),ver.end(),[&](int x,int y){return in[x]<in[y];});
		for(int i:ver) son[i].clear();
		int rt=ver[0];stk[top=1]=rt;
		for(int i:ver) if(i!=rt){
			while(!(in[stk[top]]<=in[i]&&out[i]<=out[stk[top]])) lk(stk[top-1],stk[top]),top--;
			stk[++top]=i;
		}
		while(top>1) lk(stk[top-1],stk[top]),top--;ans=0;
		dfs1(rt,0);
		cout<<(ans%MOD+MOD)%MOD<<'\n';
	}
	return 0;
}

詳細信息


Pretests


Final Tests

Test #1:

score: 5
Accepted
time: 1ms
memory: 69352kb

input:

5 10
1 1 3 1 2
1 2
2 3
2 4
3 5
1 0 2 0 3 1
2 0 3 0 1 1
2 1 1 3 3 1
2 0 3 1 1 2
2 1 3 1 1 2
2 1 3 0 1 3
3 1 1 1 2 0
3 0 2 1 1 0
3 1 1 0 2 1
2 1 3 0 1 3

output:

1
3
1
2
2
0
1
1
1
0

result:

ok 10 numbers

Test #2:

score: 0
Wrong Answer
time: 1ms
memory: 69212kb

input:

10 10
1 4 3 4 1 2 3 2 4 2
1 2
2 3
2 4
1 5
1 6
4 7
5 8
5 9
1 10
2 0 1 0 4 2
1 1 2 3 4 2
2 0 1 0 4 2
3 0 4 0 1 2
2 3 4 0 1 0
2 1 4 0 1 0
1 0 4 1 3 0
4 2 2 2 3 2
1 0 2 0 3 0
1 1 2 0 4 3

output:

1
0
1
1
0
3
3
4
2
0

result:

wrong answer 1st numbers differ - expected: '4', found: '1'

Test #3:

score: 0
Wrong Answer
time: 1ms
memory: 69184kb

input:

15 50
1 4 1 5 5 1 2 4 5 1 1 5 3 5 4
1 2
2 3
1 4
1 5
2 6
3 7
2 8
1 9
1 10
1 11
7 12
2 13
1 14
13 15
4 2 3 0 1 0
5 3 1 2 4 0
3 1 1 0 2 1
1 5 2 0 3 0
1 4 5 2 4 0
1 2 2 1 5 5
4 2 5 2 1 3
2 0 4 3 5 2
1 1 2 0 4 3
5 0 2 1 1 4
1 5 4 3 3 0
2 0 4 0 5 5
3 0 5 4 2 0
4 1 2 1 5 4
1 3 3 1 5 4
4 0 2 0 3 1
1 0 4 1 3...

output:

1
8
0
1
0
1
198
12
3
3
0
0
3
10
21
1
2
34
4
7
4
6
3
1
0
0
12
22
6
2
14
2
2
0
24
14
0
5
0
9
2
10
8
18
7
8
2
0
9
4

result:

wrong answer 4th numbers differ - expected: '32', found: '1'

Test #4:

score: 0
Wrong Answer
time: 0ms
memory: 69352kb

input:

15 50
4 4 5 2 1 1 2 4 2 2 1 5 5 1 2
1 2
2 3
3 4
3 5
4 6
4 7
4 8
1 9
7 10
3 11
9 12
12 13
4 14
3 15
3 0 5 0 1 3
4 2 2 1 5 3
4 2 1 3 2 2
4 0 3 0 2 1
4 1 5 2 1 0
4 3 2 2 5 1
2 2 3 0 1 0
5 0 2 3 1 1
5 2 3 0 1 0
4 3 5 3 3 0
5 0 3 0 4 1
1 3 5 0 4 2
1 1 2 1 4 0
5 2 1 2 2 2
3 0 2 3 5 1
1 1 2 3 5 0
2 1 1 4 4...

output:

0
1
20
7
1
3
8
2
5
12
4
0
8
7
6
2
1
2
1
1
4
36
2
4
6
10
1
1
1
3
13
7
12
8
1
2
3
10
1
1
2
6
2
0
4
2
3
12
10
0

result:

wrong answer 2nd numbers differ - expected: '4', found: '1'

Test #5:

score: 0
Wrong Answer
time: 5ms
memory: 69824kb

input:

1000 1000
266 90 111 86 237 174 221 276 192 32 249 136 98 20 228 38 223 220 284 179 255 158 140 196 241 118 48 244 165 193 51 286 159 43 176 144 69 111 36 237 145 266 271 28 288 267 30 123 200 142 227 209 11 224 298 112 170 293 100 168 259 270 47 117 188 79 206 5 166 110 100 212 14 202 1 38 279 269 ...

output:

564889328
861774363
966099271
648939909
616222404
423641883
82727123
802010780
261251664
506388976
17415079
690126513
0
223970524
238842383
916786474
983454760
92491592
834330842
852934693
387228839
551714590
820493694
42882768
102103902
277001341
252443245
618162154
691420062
519746450
320077083
47...

result:

wrong answer 1st numbers differ - expected: '65098538', found: '564889328'

Test #6:

score: 0
Wrong Answer
time: 6ms
memory: 74256kb

input:

1000 1000
118 138 198 43 181 54 128 270 49 165 18 179 169 171 113 243 51 35 174 178 48 137 156 236 219 226 20 10 291 47 142 265 165 126 40 100 247 275 250 245 200 36 289 220 13 185 231 72 10 89 94 51 162 11 177 6 139 218 190 127 220 226 38 294 61 157 256 197 250 163 142 195 76 290 150 188 127 230 13...

output:

247058064
719840637
530925391
815024799
989848567
999079028
69289426
523752570
961498323
473134144
617585801
726069794
455211917
418113571
917365722
460679305
470296176
167652637
159915272
577658929
721027959
775731762
227538110
465461983
504574229
549538627
145130663
859298731
794890695
796065546
1...

result:

wrong answer 1st numbers differ - expected: '12278776', found: '247058064'

Test #7:

score: 0
Wrong Answer
time: 497ms
memory: 157668kb

input:

50000 50000
6271 2161 8645 12531 13681 14634 4058 8472 3574 13129 10626 7913 9431 12635 654 380 1486 14727 7795 10377 3440 11216 12528 12344 12554 6566 9715 2952 4848 7701 14508 1321 415 12684 4880 9300 13148 12031 3888 3909 8411 12173 10399 4776 7962 1043 7688 5777 8995 8680 1517 6250 10677 3031 92...

output:

972312363
612616832
833929275
130188289
361282433
756234198
900164239
658406238
758260917
860415103
534532186
902011496
496471972
346060518
105734784
358854776
403077391
681593168
981049308
337592264
959964402
883742570
678936772
188735871
397020623
133313682
379294539
677157310
153188637
424156723
...

result:

wrong answer 1st numbers differ - expected: '513219003', found: '972312363'

Test #8:

score: 0
Wrong Answer
time: 1091ms
memory: 241948kb

input:

100000 100000
25323 21952 1724 4564 25924 25014 26764 1442 16456 29326 5595 29624 4770 63 21664 27749 8213 25042 9716 1308 2933 9463 25512 29592 21164 26830 19519 20594 18774 5454 2543 27277 25621 26674 3012 24923 19150 15687 28701 2117 10090 16319 3518 18167 19511 22737 8844 25650 9172 6103 8884 26...

output:

895946087
141917461
986353705
795299615
466808623
244192412
571221983
228825296
831362226
868045502
693800421
720809055
454118597
487469454
266749117
825515105
986786942
111092230
133099175
115164578
148403098
375579808
78450085
199542078
607590869
659285731
538495180
318903711
648341521
255170225
1...

result:

wrong answer 1st numbers differ - expected: '769702737', found: '895946087'

Test #9:

score: 0
Wrong Answer
time: 1684ms
memory: 243912kb

input:

100000 100000
14376 20799 15746 5653 2224 5394 22239 6237 5281 21059 25028 18159 24165 19851 28081 15653 12172 8534 11637 25007 5194 22709 17960 19200 2134 20270 28914 8237 2700 17800 29634 20465 20827 10256 28376 10955 1096 4343 5339 15325 11769 2289 8868 13791 7003 26663 12769 18699 12525 6293 103...

output:

682886042
779868621
470113227
995433392
307881046
0
433434562
86023129
7694251
841586356
282190630
881036219
207861326
455740828
99440438
490089775
0
734849409
96543711
742703343
75736864
376585921
861737878
186556382
770827069
115356334
164039297
50371222
440583765
178737890
586082858
716422329
329...

result:

wrong answer 1st numbers differ - expected: '773309997', found: '682886042'

Test #10:

score: 0
Wrong Answer
time: 1628ms
memory: 244352kb

input:

100000 100000
3428 10591 11593 9509 29468 15774 26769 29207 21338 10023 8173 22101 4504 22278 16322 790 4307 6617 16326 18706 1918 3188 25000 6040 25744 28302 26486 28647 13857 18321 14900 16420 6977 9246 11916 11578 22098 11175 11977 25765 13448 6434 1579 9415 784 589 2102 26340 24935 6484 8962 225...

output:

564596442
567680880
174554857
71108520
866926295
0
0
608678297
540329786
72545406
819914423
0
380055833
462556979
0
824906967
276240036
427795009
353262982
0
483245387
0
705931430
383423552
801343064
864837015
202653252
731304716
296771407
331364434
757675501
225634065
645871823
544017512
902304549
...

result:

wrong answer 1st numbers differ - expected: '496153554', found: '564596442'

Test #11:

score: 0
Wrong Answer
time: 1634ms
memory: 244124kb

input:

100000 100000
22481 9438 4672 10598 11304 26154 22243 19409 10163 26220 27606 7868 26666 242 7331 4103 8266 20109 21016 9638 4179 16435 20216 22880 22122 21742 24057 16289 25015 16075 2935 12376 2183 25596 7280 9434 13099 27063 4022 8973 12360 22404 9697 5038 101 4514 6026 1213 25520 3907 1329 22123...

output:

0
781772069
0
154804284
997812849
418602266
347562010
645984343
586322526
0
52558230
599906945
76884555
880943491
275589646
603216495
978714380
778195587
0
853900062
949681504
135243685
895179688
924125287
435206153
107488478
675303360
762242439
542578902
784038676
369157371
805627436
478671164
8422...

result:

wrong answer 2nd numbers differ - expected: '656312037', found: '781772069'

Test #12:

score: 0
Wrong Answer
time: 1719ms
memory: 243932kb

input:

100000 100000
8765 29229 18695 17223 5780 6534 14950 24203 26221 15185 22575 14578 16061 14494 25572 22008 3169 3601 20169 21513 3672 24146 27256 9720 324 27006 685 3931 8941 16597 18202 8332 27389 27354 23588 25465 25045 15719 10660 19414 14039 8374 2407 3430 14826 11208 7183 21494 10697 4098 2752 ...

output:

784004162
474907894
753667591
333757326
207132517
757940560
228294629
13404132
825493414
463807910
875332209
187026948
512504646
0
0
841100212
871902588
723916612
966111447
837464254
0
976369354
800611980
28816065
981084051
375574909
828859274
56052574
819292337
305617523
0
248093619
360555413
31461...

result:

wrong answer 1st numbers differ - expected: '161016891', found: '784004162'

Test #13:

score: 0
Wrong Answer
time: 1779ms
memory: 244348kb

input:

100000 100000
585 28077 11773 18312 14848 16914 22248 14405 24102 6917 184 3113 26400 22457 1989 7144 7128 28916 24858 15212 3164 25569 19703 29327 23934 23214 25488 21573 4690 14350 15293 16112 13539 8168 18952 26089 16047 22551 20066 2622 15718 12520 7758 26286 11375 12366 11108 26367 11282 1521 2...

output:

810119892
288185724
460986271
554459488
545050026
642241866
255828938
125228247
620626590
536134873
153278608
214200242
482844356
349498103
242789967
320101368
271131091
97250795
286277007
19557508
713202073
295740060
611202778
691304921
350302023
758678140
84519249
873590821
507324909
516998570
718...

result:

wrong answer 1st numbers differ - expected: '130957747', found: '810119892'

Test #14:

score: 0
Wrong Answer
time: 1763ms
memory: 243724kb

input:

100000 100000
19638 15100 4852 19400 9324 27294 14954 7375 10159 25882 25153 9824 18563 9477 22998 22281 11087 12408 26779 8911 2657 8816 17687 16167 20312 28478 25828 21039 15848 26696 6095 12067 8745 9926 5260 14889 7048 11206 14879 27654 17397 28489 27700 10086 7923 19060 440 19415 23692 13536 26...

output:

953029872
711348095
173426070
287395509
727549054
900136856
684102228
679319242
721696742
823945156
676462482
929508688
487907508
271137111
604023370
674106871
993426950
707105883
647577789
184171204
869070218
712924496
757381678
584670510
593095361
52382566
908365922
278968483
275900771
616161276
4...

result:

wrong answer 1st numbers differ - expected: '683365283', found: '953029872'

Test #15:

score: 0
Wrong Answer
time: 1720ms
memory: 243916kb

input:

100000 100000
5922 13947 27931 23257 18392 10442 7661 12169 26216 12079 14586 25590 26134 14673 8471 10186 3222 7723 1469 29842 4918 19295 21959 3007 28514 21918 2455 8681 29774 24450 21362 8023 3951 23509 624 12744 18994 27094 21517 10862 19076 14459 8587 5709 25416 4810 4365 27056 29813 10959 2796...

output:

43444249
310252784
870248974
248757122
694337915
818345094
244968278
287496435
699519376
941869415
0
480587507
27751139
53753601
199964367
946743336
43910231
971645197
989231014
748074262
804523955
291793351
503695966
13023768
82502258
791382181
957614194
910392448
366761384
966446597
207708555
3408...

result:

wrong answer 1st numbers differ - expected: '891039068', found: '43444249'

Test #16:

score: 0
Wrong Answer
time: 1731ms
memory: 244120kb

input:

100000 100000
24975 6507 11954 24346 15636 20822 12191 5139 15041 3811 27731 11357 18296 19868 17656 25323 7182 21215 622 23541 1642 2542 19943 22615 22124 27182 27 26323 13699 22203 18453 3979 20101 25267 25988 13368 9996 15750 16331 21302 20755 21373 16705 1333 19197 8736 5521 29161 12222 8382 175...

output:

34600281
398497234
556252385
145630606
297035835
536537313
26855036
599302991
580817863
389604791
484511478
612429908
939490187
368800265
271654398
757036880
635237924
212639154
272025599
785985650
257138932
303309855
540051633
554388409
585727473
23645606
206890378
931935111
497089009
46605353
5609...

result:

wrong answer 1st numbers differ - expected: '91903992', found: '34600281'

Test #17:

score: 0
Wrong Answer
time: 1694ms
memory: 244344kb

input:

100000 100000
16795 5354 7800 28203 24704 1202 7665 25341 1099 10952 17164 18067 28635 6888 5897 13227 2085 19299 5311 17240 3903 10253 24215 9455 326 26158 9423 13965 24857 22725 6488 29935 15308 6081 9528 29399 997 22582 22968 1742 7842 7342 3879 29725 18514 12662 6678 22210 12807 8573 18986 15730...

output:

586833347
784504928
933713223
851025929
601203355
296545503
266698164
748776881
811771659
366509356
791769915
476495656
883895365
657598110
341283180
321607237
35385875
201005869
198476429
466203758
784792979
544839084
534162658
914302993
577493340
764501633
570032479
338430418
814146788
542949752
1...

result:

wrong answer 1st numbers differ - expected: '605580638', found: '586833347'

Test #18:

score: 0
Wrong Answer
time: 1731ms
memory: 243768kb

input:

100000 100000
3079 22377 879 29291 21948 11582 372 27367 19924 29917 12133 6602 18030 12084 24138 28364 6044 2790 10000 10939 3396 23499 19431 26295 26704 19599 6994 28839 8783 2303 21754 25890 13282 7839 4892 27255 10175 11238 29606 14950 9521 11488 14766 22580 471 19356 28779 27083 27985 8763 1135...

output:

215898079
684550188
745558642
916102247
843535640
885972613
797018423
160282017
205486266
102663329
111470646
491284718
968854116
936390215
655127203
201140526
873057969
819519072
189816795
405052644
63444807
993513139
129670535
353891189
603427577
5777276
92912247
400759401
473795016
723588378
6418...

result:

wrong answer 1st numbers differ - expected: '758706683', found: '215898079'

Test #19:

score: 0
Wrong Answer
time: 1741ms
memory: 243920kb

input:

100000 100000
22132 9401 14902 21324 28248 21962 7670 20337 17805 16113 22510 13313 28369 17279 3323 13501 28179 28106 11921 20046 120 6746 26471 1311 23082 24863 1798 16481 22708 2824 21613 21846 29432 24189 18432 16055 3945 29894 24420 25390 11201 27458 4708 20972 29787 20513 29935 1956 28570 6186...

output:

22801907
557880051
12587603
903946695
649267002
545498851
469357023
686983314
667358903
261288521
532887494
304278103
985118358
717558594
398281042
213254600
549776493
577457473
549778561
753359007
45999424
651224612
5062935
542267323
318482903
305714024
203099302
73207191
748948321
975792048
507102...

result:

wrong answer 1st numbers differ - expected: '576116885', found: '22801907'

Test #20:

score: 0
Wrong Answer
time: 1728ms
memory: 243936kb

input:

100000 100000
11184 11016 7980 22413 25492 2342 376 10540 3862 7846 14711 29079 20531 4299 21564 1405 2138 11597 13843 13745 2381 17225 21686 20919 28516 18303 11193 4123 3866 578 6880 29626 24638 23179 16563 16678 24947 3958 28289 11366 12880 13428 12826 16596 26336 27207 3860 25005 10979 6377 1696...

output:

570858445
765731070
873440143
815223815
479419892
524744094
712512938
97088067
848217220
637455643
809663816
889740760
577199443
960040363
997301168
296358556
538511613
844710860
944290017
263150130
411025350
836320311
827165634
502448846
0
983391145
371493827
344821191
8024967
164076748
78063865
37...

result:

wrong answer 1st numbers differ - expected: '13770602', found: '570858445'