QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#618340#8340. 3 Sumucup-team963#WA 182ms3916kbC++141.4kb2024-10-06 21:06:462024-10-06 21:06:46

Judging History

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

  • [2024-10-06 21:06:46]
  • 评测
  • 测评结果:WA
  • 用时:182ms
  • 内存:3916kb
  • [2024-10-06 21:06:46]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+9;
int fp(int a,int b){
	int res=1;
	for(;b;b>>=1,a=1ll*a*a%mod)
		if(b&1)
			res=1ll*res*a%mod;
	return res;
}
const int N=200011;
#define rep(i,s,t) for(int i=s;i<=t;++i)
#define ll long long
const int mod1=1e9+7,mod2=1e9+9;
int n,k;
char s[N];
int d[N];
int a[N],b[N];
int a1,b1,a2,b2,a3,b3;
int main(){
	scanf("%d%d",&n,&k);
	rep(i,1,n){
		scanf("%s",s);
		int len=strlen(s);
		reverse(s,s+len);
		rep(j,0,k-1)
			d[j]=0;
		rep(j,0,len-1)
			d[j%k]+=(s[j]-'0');
		rep(j,0,len-1)
			d[(j+1)%k]+=d[j%k]/10,d[j%k]%=10;
		for(int j=k-1;~j;--j){
			a[i]=(a[i]*10+d[j])%mod1;
			b[i]=(b[i]*10+d[j])%mod2;
		}
	}
	a2=b2=1;
	for(int j=k-1;j;--j){
		a2=(a2*10+9)%mod1;
		b2=(b2*10+9)%mod2;
	}
	a2=(a2*10+8)%mod1;
	b2=(b2*10+8)%mod2;
	a3=b3=2;
	for(int j=k-1;j;--j){
		a3=(a3*10+9)%mod1;
		b3=(b3*10+9)%mod2;
	}
	a3=(a3*10+7)%mod1;
	b3=(b3*10+7)%mod2;
	for(int j=k-1;~j;--j){
		a1=(a1*10+9)%mod1;
		b1=(b1*10+9)%mod2;
	}
	int ans=0;
	rep(i,1,n)
		rep(j,i,n)
			rep(k,j,n){
				int aa=a[i]+a[j]+a[k],bb=b[i]+b[j]+b[k];
				if(aa>=mod1)aa-=mod1;
				if(aa>=mod1)aa-=mod1;
				if(bb>=mod2)bb-=mod2;
				if(bb>=mod2)bb-=mod2;
				if((aa==0&&bb==0)||(aa==a1&&bb==b1)||(aa==a2&&bb==b2)||(aa==a3&&bb==b3))
					++ans;
			}
	printf("%d\n",ans);
	return 0;
}
/*
4 1
0
1
10
17
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4 1
0
1
10
17

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: 0
Accepted
time: 82ms
memory: 3780kb

input:

500 859
7118711592236878297922359501613604144948355616986970837340677671376753603836852811886591300370143151943368529129749813118476151865844255212534355441611481420938483178075143062691345257288242460282715389758789648541099090735875617822348551942134616963557723055980260082230902505269975518146286...

output:

0

result:

ok 1 number(s): "0"

Test #3:

score: 0
Accepted
time: 182ms
memory: 3916kb

input:

500 17336
11871159223687829792235950161360414494835561698697083734067767137675360383685281188659130037014315194336852912974981311847615186584425521253435544161148142093848317807514306269134525728824246028271538975878964854109909073587561782234855194213461696355772305598026008223090250526997551814628...

output:

0

result:

ok 1 number(s): "0"

Test #4:

score: -100
Wrong Answer
time: 152ms
memory: 3848kb

input:

500 1
751324443898124078584847834484321089092662321556147445230263526014359393841194947303407593948729802551881289193716611867931891257925091769456350249725997883453296895094445731130479434019358742162771547784250401546380268386074363779242500860317042151185119666027858022664683818314351285215150806...

output:

2333543

result:

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