QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#618419 | #8340. 3 Sum | ucup-team963# | WA | 175ms | 6048kb | C++14 | 1.4kb | 2024-10-06 21:56:14 | 2024-10-06 21:56:14 |
Judging History
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
#define int long long
const int mod1=1e17+7,mod2=1e17+9;
int n,k;
char s[N];
int d[N];
int a[N],b[N];
int a1,b1,a2,b2,a3,b3;
main(){
scanf("%lld%lld",&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]*10ll+d[j])%mod1;
b[i]=(b[i]*10ll+d[j])%mod2;
}
}
a2=b2=1;
for(int j=k-1;j;--j){
a2=(a2*10ll+9)%mod1;
b2=(b2*10ll+9)%mod2;
}
a2=(a2*10ll+8)%mod1;
b2=(b2*10ll+8)%mod2;
a3=b3=2;
for(int j=k-1;j;--j){
a3=(a3*10ll+9)%mod1;
b3=(b3*10ll+9)%mod2;
}
a3=(a3*10ll+7)%mod1;
b3=(b3*10ll+7)%mod2;
for(int j=k-1;~j;--j){
a1=(a1*10ll+9)%mod1;
b1=(b1*10ll+9)%mod2;
}
int ans=0;
rep(i,1,n)
rep(j,i,n)
rep(k,j,n){
int aa=a[i]+a[j],bb=b[i]+b[j];
if(aa>=mod1)aa-=mod1;
aa+=a[k];
if(aa>=mod1)aa-=mod1;
if(bb>=mod2)bb-=mod2;
bb+=b[k];
if(bb>=mod2)bb-=mod2;
if((aa==0&&bb==0)||(aa==a1&&bb==b1)||(aa==a2&&bb==b2)||(aa==a3&&bb==b3))
++ans;
}
printf("%lld\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: 1ms
memory: 5956kb
input:
4 1 0 1 10 17
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 51ms
memory: 5912kb
input:
500 859 7118711592236878297922359501613604144948355616986970837340677671376753603836852811886591300370143151943368529129749813118476151865844255212534355441611481420938483178075143062691345257288242460282715389758789648541099090735875617822348551942134616963557723055980260082230902505269975518146286...
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: 0
Accepted
time: 175ms
memory: 6048kb
input:
500 17336 11871159223687829792235950161360414494835561698697083734067767137675360383685281188659130037014315194336852912974981311847615186584425521253435544161148142093848317807514306269134525728824246028271538975878964854109909073587561782234855194213461696355772305598026008223090250526997551814628...
output:
0
result:
ok 1 number(s): "0"
Test #4:
score: -100
Wrong Answer
time: 168ms
memory: 5904kb
input:
500 1 751324443898124078584847834484321089092662321556147445230263526014359393841194947303407593948729802551881289193716611867931891257925091769456350249725997883453296895094445731130479434019358742162771547784250401546380268386074363779242500860317042151185119666027858022664683818314351285215150806...
output:
2333543
result:
wrong answer 1st numbers differ - expected: '2327631', found: '2333543'