QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#785380#9651. 又一个欧拉数问题zhouhuanyi100 ✓1592ms60988kbC++178.1kb2024-11-26 17:43:412024-11-26 17:43:42

Judging History

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

  • [2024-11-26 17:43:42]
  • 评测
  • 测评结果:100
  • 用时:1592ms
  • 内存:60988kb
  • [2024-11-26 17:43:41]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#define K 18
#define N 200000
#define M 262144
#define Z 4
#define g 3
#define mod 998244353
using namespace std;
int read()
{
	char c=0;
	int sum=0;
	while (c<'0'||c>'9') c=getchar();
	while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
	return sum;
}
int MD(int x)
{
	return x>=mod?x-mod:x;
}
int MD2(int x)
{
	return x<0?x+mod:x;
}
void Adder(int &x,int d)
{
	x=x+d>=mod?x+d-mod:x+d;
	return;
}
void Adder2(int &x,int d)
{
	x=x+d<0?x+d+mod:x+d;
	return;
}
int fast_pow(int a,int b)
{
	int res=1,mul=a;
	while (b)
	{
		if (b&1) res=1ll*res*mul%mod;
		mul=1ll*mul*mul%mod,b>>=1;
	}
	return res;
}
int n,k,length,F[N+1],G[N+1][2][2],H[N+1][2][2][2][2],dp[N+1],DP[N+1][2],delta[N+1][2][2],A[M+1],B[M+1],C[M+1],D[M+1],fac[N+1],invfac[N+1],inv[N+1],num[M+1],rev[M+1],wn[K+1][M+1],wn2[K+1][M+1],w[1<<Z];
void NTT(int limit,int *s,int type)
{
	int s1,s2;
	for (int i=1;i<limit;++i) rev[i]=(rev[i>>1]>>1)|((i&1)?limit>>1:0);
	for (int i=0;i<limit;++i)
		if (rev[i]>i)
			swap(s[i],s[rev[i]]);
	if (type==1)
	{
		for (int i=2;i<=limit;i<<=1)
			for (int j=0;j+i-1<limit;j+=i)
				for (int k=j;k<(j|(i>>1));++k)
					s1=s[k],s2=1ll*s[k|(i>>1)]*wn[num[i]][k-j]%mod,s[k]=MD(s1+s2),s[k+(i>>1)]=MD2(s1-s2);
	}
	else
	{
		for (int i=2;i<=limit;i<<=1)
			for (int j=0;j+i-1<limit;j+=i)
				for (int k=j;k<(j|(i>>1));++k)
					s1=s[k],s2=1ll*s[k|(i>>1)]*wn2[num[i]][k-j]%mod,s[k]=MD(s1+s2),s[k+(i>>1)]=MD2(s1-s2);
		s1=fast_pow(limit,mod-2);
		for (int i=0;i<=limit;++i) s[i]=1ll*s[i]*s1%mod;
	}
	return;
}
vector<int>operator + (vector<int>a,vector<int>b)
{
	if (a.size()<b.size()) swap(a,b);
	for (int i=0;i<b.size();++i) Adder(a[i],b[i]);
	return a;
}
vector<int>operator - (vector<int>a,vector<int>b)
{
	if (a.size()<b.size()) a.resize(b.size());
	for (int i=0;i<b.size();++i) Adder2(a[i],-b[i]);
	return a;
}
vector<int>operator * (vector<int>a,int d)
{
	for (int i=0;i<a.size();++i) a[i]=1ll*a[i]*d%mod;
	return a;
}
vector<int>operator * (vector<int>a,vector<int>b)
{
	if (a.empty()) return a;
	if (b.empty()) return b;
	vector<int>c(a.size()+b.size()-1);
	if (min(a.size(),b.size())<=50)
	{
		for (int i=0;i<a.size();++i)
			for (int j=0;j<b.size();++j)
				Adder(c[i+j],1ll*a[i]*b[j]%mod);
		return c;
	}
	int limit=1;
	while (limit<=a.size()+b.size()) limit<<=1;
	for (int i=0;i<=limit;++i) A[i]=B[i]=0;
	for (int i=0;i<a.size();++i) A[i]=a[i];
	for (int i=0;i<b.size();++i) B[i]=b[i];
	NTT(limit,A,1),NTT(limit,B,1);
	for (int i=0;i<=limit;++i) A[i]=1ll*A[i]*B[i]%mod;
	NTT(limit,A,-1);
	for (int i=0;i<c.size();++i) c[i]=A[i];
	return c;
}
vector<int>operator ^ (vector<int>a,vector<int>b)
{
	vector<int>c(a.size()-b.size()+1);
	if (min(b.size(),c.size())<=50)
	{
		for (int i=0;i<c.size();++i)
			for (int j=0;j<b.size();++j)
				Adder(c[i],1ll*b[j]*a[i+j]%mod);
		return c;
	}
	int limit=1;
	while (limit<=a.size()) limit<<=1;
	for (int i=0;i<=limit;++i) A[i]=B[i]=0;
	for (int i=0;i<a.size();++i) A[i]=a[i];
	for (int i=0;i<b.size();++i) B[b.size()-i]=b[i];
	NTT(limit,A,1),NTT(limit,B,1);
	for (int i=0;i<=limit;++i) A[i]=1ll*A[i]*B[i]%mod;
	NTT(limit,A,-1);
	for (int i=0;i<c.size();++i) c[i]=A[b.size()+i];
	return c;
}
vector<int>get_rev(int sz,vector<int>a)
{
	a.resize(sz+1),reverse(a.begin(),a.end());
	return a;
}
void calc_inv(int len,int *s1,int *s2)
{
	if (len==1)
	{
		s2[0]=fast_pow(s1[0],mod-2);
		return;
	}
	int limit=1;
	while (limit<=(len<<1)) limit<<=1;
	calc_inv((len+1)>>1,s1,s2);
	int s3[limit+1];
	for (int i=0;i<=limit;++i) s2[i]=i<((len+1)>>1)?s2[i]:0,s3[i]=i<len?s1[i]:0;
	NTT(limit,s2,1),NTT(limit,s3,1);
	for (int i=0;i<=limit;++i) s2[i]=MD2(2ll*s2[i]%mod-1ll*s2[i]*s2[i]%mod*s3[i]%mod);
	NTT(limit,s2,-1);
	return;
}
vector<int>get_inv(int len,vector<int>p)
{
	vector<int>v(len);
	for (int i=0;i<len;++i) A[i]=i<p.size()?p[i]:0;
	calc_inv(len,A,B);
	for (int i=0;i<len;++i) v[i]=B[i];
	return v;
}
void solve(int l,int r)
{
	if (l==r) return;
	int mid=(l+r)>>1;
	vector<int>p(mid-l+1);
	vector<int>q(r-l+1);
	solve(l,mid);
	for (int i=l;i<=mid;++i) p[i-l]=dp[i];
	for (int i=1;i<=r-l;++i) q[i]=1ll*F[i]*w[0]%mod;
	p=p*q;
	for (int i=mid+1;i<=r;++i) Adder(dp[i],p[i-l]);
	solve(mid+1,r);
	return;
}
void solve2(int l,int r)
{
	if (l==r) return;
	int mid=(l+r)>>1;
	vector<int>p(mid-l+1);
	vector<int>q(r-l+1);
	vector<int>z(r-l+1);
	solve2(l,mid);
	for (int i=l;i<=mid;++i) p[i-l]=MD(1ll*DP[i][0]*w[0]%mod+1ll*DP[i][1]*w[1]%mod);
	for (int i=1;i<=r-l;++i) q[i]=1ll*G[i-1][0][0]*invfac[i]%mod,z[i]=1ll*G[i-1][0][1]*invfac[i]%mod;
	q=p*q,z=p*z;
	for (int i=mid+1;i<=r;++i) Adder(DP[i][0],q[i-l]),Adder(DP[i][1],z[i-l]);
	solve2(mid+1,r);
	return;
}
void solve3(int l,int r)
{
	if (l==r) return;
	int mid=(l+r)>>1;
	vector<int>p[2];
	vector<int>q(r-l+1);
	vector<int>z;
	for (int op=0;op<=1;++op) p[op].resize(mid-l+1);
	solve3(l,mid);
	for (int i=l;i<=mid;++i)
		for (int op=0;op<=1;++op)
			for (int op2=0;op2<=1;++op2)
				Adder(p[op2][i-l],1ll*delta[i][op][op2]*w[op|(op2<<1)]%mod);
	for (int op=0;op<=1;++op)
		for (int op2=0;op2<=1;++op2)
			for (int op3=0;op3<=1;++op3)
			{
				for (int i=1;i<=r-l;++i) q[i]=1ll*H[i-1][op][0][op2][op3]*invfac[i]%mod;
				z=p[op]*q;
				for (int i=mid+1;i<=r;++i) Adder(delta[i][op2][op3],z[i-l]);
			}
	solve3(mid+1,r);
	return;
}
int main()
{
	fac[0]=1;
	for (int i=1;i<=N;++i) fac[i]=1ll*fac[i-1]*i%mod;
	invfac[N]=fast_pow(fac[N],mod-2);
	for (int i=N-1;i>=0;--i) invfac[i]=1ll*invfac[i+1]*(i+1)%mod;
	for (int i=1;i<=N;++i) inv[i]=1ll*fac[i-1]*invfac[i]%mod;
	for (int i=2,w;i<=M;i<<=1)
	{
		num[i]=++length,w=fast_pow(g,(mod-1)/i);
		for (int j=0,res=1;j<(i>>1);++j,res=1ll*res*w%mod) wn[num[i]][j]=res;
		w=fast_pow(g,(mod-1)/i*(i-1));
		for (int j=0,res=1;j<(i>>1);++j,res=1ll*res*w%mod) wn2[num[i]][j]=res;
	}
	n=read(),k=read();
	for (int i=0;i<(1<<(k-1));++i) w[i]=read();
	if (k==2)
	{
		for (int i=1,res=1;i<=n;++i,res=1ll*res*MD2(w[1]-w[0])%mod) F[i]=1ll*res*invfac[i]%mod;
		for (int i=1;i<=n;++i) Adder(dp[i],F[i]);
		solve(1,n),printf("%lld\n",1ll*dp[n]*fac[n]%mod);
	}
	else if (k==3)
	{
		G[0][0][0]=G[0][1][1]=1;
		for (int i=1;i<=n;++i)
			for (int op=0;op<=1;++op)
				for (int op2=0;op2<=1;++op2)
					for (int op3=0;op3<=1;++op3)
					{
						if (!op3) Adder2(G[i][op][op3],-1ll*G[i-1][op][op2]*w[op2|(op3<<1)]%mod);
						else Adder(G[i][op][op3],1ll*G[i-1][op][op2]*w[op2|(op3<<1)]%mod);
					}
		for (int i=2;i<=n;++i)
		{
			Adder(DP[i][0],1ll*G[i-2][1][0]*invfac[i]%mod),Adder(DP[i][1],1ll*G[i-2][1][1]*invfac[i]%mod);
			Adder2(DP[i][0],-1ll*G[i-2][0][0]*invfac[i]%mod),Adder2(DP[i][1],-1ll*G[i-2][0][1]*invfac[i]%mod);
			Adder(DP[i][0],1ll*G[i-2][0][0]*invfac[i-1]%mod),Adder(DP[i][1],1ll*G[i-2][0][1]*invfac[i-1]%mod);
		}
		solve2(1,n),printf("%lld\n",1ll*MD(DP[n][0]+DP[n][1])*fac[n]%mod);
	}
	else
	{
		for (int op=0;op<=1;++op)
			for (int op2=0;op2<=1;++op2)
				H[0][op][op2][op][op2]=1;
		for (int i=1;i<=n;++i)
			for (int op=0;op<=1;++op)
				for (int op2=0;op2<=1;++op2)
					for (int op3=0;op3<=1;++op3)
						for (int op4=0;op4<=1;++op4)
							for (int op5=0;op5<=1;++op5)
							{
								if (!op5) Adder2(H[i][op][op2][op4][op5],-1ll*H[i-1][op][op2][op3][op4]*w[op3|(op4<<1)|(op5<<2)]%mod);
								else Adder(H[i][op][op2][op4][op5],1ll*H[i-1][op][op2][op3][op4]*w[op3|(op4<<1)|(op5<<2)]%mod);
							}
		for (int i=3;i<=n;++i)
			for (int op=0;op<=2;++op)
				for (int op2=0,res;op2<=2;++op2)
				{
					res=1;
					if (op==1) res=MD2(-res);
					if (op2==1) res=MD2(-res);
					if (op==2&&op2==2) res=1ll*res*invfac[i-2]%mod;
					else if (op==2&&op2!=2) res=1ll*res*invfac[i-1]%mod;
					else if (op!=2&&op2==2) res=1ll*res*invfac[i-2]%mod*invfac[2]%mod;
					else res=1ll*res*invfac[i]%mod;
					for (int op3=0;op3<=1;++op3)
						for (int op4=0;op4<=1;++op4)
							Adder(delta[i][op3][op4],1ll*H[i-3][!op][!op2][op3][op4]*res%mod);
				}
		solve3(1,n),printf("%lld\n",1ll*MD(MD(delta[n][0][0]+delta[n][0][1])+MD(delta[n][1][0]+delta[n][1][1]))*fac[n]%mod);
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 5
Accepted

Test #1:

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

input:

4 4
698120943 122288832 680575548 463848799 156774757 854895700 608223343 677744207

output:

129451994

result:

ok 1 number(s): "129451994"

Test #2:

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

input:

5 4
550891357 916542306 749948554 123704496 62951279 389103312 185283715 952036050

output:

603530316

result:

ok 1 number(s): "603530316"

Test #3:

score: 5
Accepted
time: 8ms
memory: 51168kb

input:

5 4
0 0 0 0 0 0 0 0

output:

0

result:

ok 1 number(s): "0"

Test #4:

score: 5
Accepted
time: 4ms
memory: 48836kb

input:

9 4
932794876 983187846 61110015 10089567 242406926 990649413 302889463 707289292

output:

623984278

result:

ok 1 number(s): "623984278"

Test #5:

score: 5
Accepted
time: 8ms
memory: 48876kb

input:

10 4
0 0 0 0 0 0 0 0

output:

0

result:

ok 1 number(s): "0"

Test #6:

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

input:

7 4
75656923 89231235 268411832 331473274 613621490 724088841 938061331 436247598

output:

828280933

result:

ok 1 number(s): "828280933"

Subtask #2:

score: 10
Accepted

Dependency #1:

100%
Accepted

Test #7:

score: 10
Accepted
time: 8ms
memory: 49032kb

input:

17 4
502378168 0 899256313 98988040 502378168 899256313 495866185 403390128

output:

955634034

result:

ok 1 number(s): "955634034"

Test #8:

score: 10
Accepted
time: 3ms
memory: 48836kb

input:

12 4
973896694 511296006 0 486948347 0 0 486948347 511296006

output:

717853738

result:

ok 1 number(s): "717853738"

Test #9:

score: 10
Accepted
time: 3ms
memory: 50924kb

input:

19 4
0 0 0 0 0 0 0 0

output:

0

result:

ok 1 number(s): "0"

Test #10:

score: 10
Accepted
time: 4ms
memory: 49056kb

input:

11 4
419369069 674825741 201692543 290396938 869076983 225876646 409445596 934556751

output:

579300967

result:

ok 1 number(s): "579300967"

Test #11:

score: 10
Accepted
time: 4ms
memory: 49064kb

input:

16 4
399991278 671519396 535203044 718737955 71028311 806731162 326724957 940847965

output:

842945071

result:

ok 1 number(s): "842945071"

Test #12:

score: 10
Accepted
time: 3ms
memory: 48804kb

input:

17 4
836771329 338008804 131570815 515413785 262236691 408466186 362787701 152542617

output:

293433305

result:

ok 1 number(s): "293433305"

Subtask #3:

score: 5
Accepted

Test #13:

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

input:

2 2
0 0

output:

0

result:

ok 1 number(s): "0"

Test #14:

score: 5
Accepted
time: 6ms
memory: 46792kb

input:

3 2
0 142044554

output:

704013496

result:

ok 1 number(s): "704013496"

Test #15:

score: 5
Accepted
time: 7ms
memory: 46756kb

input:

4 2
0 0

output:

0

result:

ok 1 number(s): "0"

Test #16:

score: 5
Accepted
time: 7ms
memory: 47016kb

input:

5 2
0 0

output:

0

result:

ok 1 number(s): "0"

Test #17:

score: 5
Accepted
time: 203ms
memory: 53024kb

input:

99487 2
0 0

output:

0

result:

ok 1 number(s): "0"

Test #18:

score: 5
Accepted
time: 197ms
memory: 53016kb

input:

99738 2
693173587 283412622

output:

815899210

result:

ok 1 number(s): "815899210"

Subtask #4:

score: 10
Accepted

Test #19:

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

input:

3 3
977925087 204858071 813705548 204858071

output:

225177337

result:

ok 1 number(s): "225177337"

Test #20:

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

input:

4 3
455457192 542787161 728591379 0

output:

494572650

result:

ok 1 number(s): "494572650"

Test #21:

score: 10
Accepted
time: 8ms
memory: 50904kb

input:

5 3
280102847 175353772 822890581 718141506

output:

0

result:

ok 1 number(s): "0"

Test #22:

score: 10
Accepted
time: 8ms
memory: 49056kb

input:

93 3
517938077 480306276 173009841 0

output:

132737095

result:

ok 1 number(s): "132737095"

Test #23:

score: 10
Accepted
time: 4ms
memory: 48840kb

input:

85 3
812966373 8069068 241411799 241442405

output:

835292882

result:

ok 1 number(s): "835292882"

Test #24:

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

input:

93 3
740309863 562024812 723775833 67304547

output:

79626905

result:

ok 1 number(s): "79626905"

Subtask #5:

score: 10
Accepted

Dependency #4:

100%
Accepted

Test #25:

score: 10
Accepted
time: 11ms
memory: 50968kb

input:

3204 3
390926493 321900190 164112702 172373440

output:

25228045

result:

ok 1 number(s): "25228045"

Test #26:

score: 10
Accepted
time: 8ms
memory: 50844kb

input:

118 3
0 0 0 0

output:

0

result:

ok 1 number(s): "0"

Test #27:

score: 10
Accepted
time: 7ms
memory: 52964kb

input:

1812 3
743708154 0 458364972 539879381

output:

369996118

result:

ok 1 number(s): "369996118"

Test #28:

score: 10
Accepted
time: 11ms
memory: 53112kb

input:

3997 3
506494422 310846999 0 0

output:

180977771

result:

ok 1 number(s): "180977771"

Test #29:

score: 10
Accepted
time: 13ms
memory: 51096kb

input:

3919 3
850826367 581870616 262788170 385598679

output:

718155036

result:

ok 1 number(s): "718155036"

Test #30:

score: 10
Accepted
time: 11ms
memory: 50952kb

input:

3908 3
268833736 15860337 13324648 101653332

output:

307317750

result:

ok 1 number(s): "307317750"

Subtask #6:

score: 15
Accepted

Dependency #5:

100%
Accepted

Test #31:

score: 15
Accepted
time: 84ms
memory: 53824kb

input:

27617 3
649538421 649538421 697411864 348705932

output:

147599656

result:

ok 1 number(s): "147599656"

Test #32:

score: 15
Accepted
time: 91ms
memory: 54168kb

input:

32594 3
0 0 0 0

output:

0

result:

ok 1 number(s): "0"

Test #33:

score: 15
Accepted
time: 41ms
memory: 51536kb

input:

18203 3
971232001 436685091 53582375 579077060

output:

15944343

result:

ok 1 number(s): "15944343"

Test #34:

score: 15
Accepted
time: 96ms
memory: 53772kb

input:

39024 3
761026701 107837672 107837672 129379980

output:

733762036

result:

ok 1 number(s): "733762036"

Test #35:

score: 15
Accepted
time: 97ms
memory: 54620kb

input:

39934 3
860432642 218393709 0 137811711

output:

959310258

result:

ok 1 number(s): "959310258"

Test #36:

score: 15
Accepted
time: 88ms
memory: 53948kb

input:

39441 3
647870660 428771613 299764381 537645434

output:

403002156

result:

ok 1 number(s): "403002156"

Subtask #7:

score: 5
Accepted

Dependency #6:

100%
Accepted

Test #37:

score: 5
Accepted
time: 193ms
memory: 54904kb

input:

65961 3
573372243 470586592 899656037 952529871

output:

727883299

result:

ok 1 number(s): "727883299"

Test #38:

score: 5
Accepted
time: 404ms
memory: 57520kb

input:

95856 3
657353865 0 340890488 0

output:

443504623

result:

ok 1 number(s): "443504623"

Test #39:

score: 5
Accepted
time: 99ms
memory: 52212kb

input:

43044 3
735177548 164240636 263066805 263066805

output:

357165044

result:

ok 1 number(s): "357165044"

Test #40:

score: 5
Accepted
time: 398ms
memory: 56304kb

input:

99124 3
0 626743689 688853562 309390791

output:

488790683

result:

ok 1 number(s): "488790683"

Test #41:

score: 5
Accepted
time: 407ms
memory: 57872kb

input:

99895 3
599127905 0 269443581 399116448

output:

308060904

result:

ok 1 number(s): "308060904"

Test #42:

score: 5
Accepted
time: 398ms
memory: 56368kb

input:

99441 3
81228584 583326742 103263243 128429203

output:

142331215

result:

ok 1 number(s): "142331215"

Subtask #8:

score: 10
Accepted

Dependency #2:

100%
Accepted

Test #43:

score: 10
Accepted
time: 4ms
memory: 48788kb

input:

4 4
0 0 0 0 0 0 0 0

output:

0

result:

ok 1 number(s): "0"

Test #44:

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

input:

5 4
719850794 868458999 534771757 496641034 108328567 58126453 451622145 127965210

output:

199502123

result:

ok 1 number(s): "199502123"

Test #45:

score: 10
Accepted
time: 15ms
memory: 51264kb

input:

1620 4
575012072 993907457 465640749 414558489 536940500 884536134 536940500 579348968

output:

276727543

result:

ok 1 number(s): "276727543"

Test #46:

score: 10
Accepted
time: 13ms
memory: 51220kb

input:

2000 4
583522935 653359292 238637874 720209712 120795105 906170921 202280741 436530633

output:

247950749

result:

ok 1 number(s): "247950749"

Test #47:

score: 10
Accepted
time: 19ms
memory: 53064kb

input:

1903 4
0 0 0 0 0 0 0 0

output:

0

result:

ok 1 number(s): "0"

Test #48:

score: 10
Accepted
time: 19ms
memory: 53316kb

input:

1970 4
634852705 681848099 480528749 96325370 426074420 662814695 282626889 407588785

output:

358841946

result:

ok 1 number(s): "358841946"

Subtask #9:

score: 10
Accepted

Dependency #8:

100%
Accepted

Test #49:

score: 10
Accepted
time: 338ms
memory: 54160kb

input:

35788 4
137592553 167362125 666174864 893867308 935259273 409053348 908484962 421828880

output:

317183526

result:

ok 1 number(s): "317183526"

Test #50:

score: 10
Accepted
time: 144ms
memory: 51540kb

input:

13180 4
455644004 629655674 433939914 99482062 167912374 215744296 744048010 856909532

output:

724269763

result:

ok 1 number(s): "724269763"

Test #51:

score: 10
Accepted
time: 319ms
memory: 52436kb

input:

25810 4
50511582 266090813 782665122 316602395 681641958 25053907 922678864 732153540

output:

316456760

result:

ok 1 number(s): "316456760"

Test #52:

score: 10
Accepted
time: 353ms
memory: 52740kb

input:

39626 4
0 0 0 0 0 0 0 0

output:

0

result:

ok 1 number(s): "0"

Test #53:

score: 10
Accepted
time: 347ms
memory: 53872kb

input:

39520 4
304751689 247786932 175360249 662006566 300713484 967876352 912150432 961654612

output:

581564252

result:

ok 1 number(s): "581564252"

Test #54:

score: 10
Accepted
time: 360ms
memory: 56216kb

input:

39654 4
199691859 32920622 161790938 562758769 16726982 895821371 135168521 518536619

output:

389091873

result:

ok 1 number(s): "389091873"

Subtask #10:

score: 20
Accepted

Dependency #9:

100%
Accepted

Test #55:

score: 20
Accepted
time: 770ms
memory: 57172kb

input:

70610 4
68292738 168290466 829953887 829953887 168290466 929951615 99997728 829953887

output:

139356701

result:

ok 1 number(s): "139356701"

Test #56:

score: 20
Accepted
time: 811ms
memory: 60692kb

input:

83154 4
40222982 0 40222982 40222982 958021371 0 877575407 0

output:

810635777

result:

ok 1 number(s): "810635777"

Test #57:

score: 20
Accepted
time: 705ms
memory: 55836kb

input:

50832 4
105333371 857557033 892910982 260281951 843295773 154948580 892910982 892910982

output:

241653357

result:

ok 1 number(s): "241653357"

Test #58:

score: 20
Accepted
time: 1591ms
memory: 60004kb

input:

99201 4
259092713 0 0 811163900 446173166 552071187 739151640 187080453

output:

150187101

result:

ok 1 number(s): "150187101"

Test #59:

score: 20
Accepted
time: 1591ms
memory: 59540kb

input:

99797 4
367311954 251136106 555832002 724805462 945161134 244359464 684015618 92172056

output:

25758638

result:

ok 1 number(s): "25758638"

Test #60:

score: 20
Accepted
time: 1592ms
memory: 60988kb

input:

99065 4
671004682 687177570 888521328 363461538 143576590 52815535 910840671 989086834

output:

379711332

result:

ok 1 number(s): "379711332"