QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#618397 | #8340. 3 Sum | ucup-team963# | Compile Error | / | / | C++14 | 1.4kb | 2024-10-06 21:47:15 | 2024-10-06 21:47:16 |
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
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]*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){
longlong 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(aa>=mod1)aa-=mod1;
if(bb>=mod2)bb-=mod2;
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
*/
詳細信息
answer.code: In function ‘int main()’: answer.code:59:33: error: ‘longlong’ was not declared in this scope 59 | longlong aa=a[i]+a[j]+a[k],bb=b[i]+b[j]+b[k]; | ^~~~~~~~ answer.code:60:36: error: ‘aa’ was not declared in this scope; did you mean ‘a3’? 60 | if(aa>=mod1)aa-=mod1; | ^~ | a3 answer.code:61:36: error: ‘aa’ was not declared in this scope; did you mean ‘a3’? 61 | if(aa>=mod1)aa-=mod1; | ^~ | a3 answer.code:62:36: error: ‘aa’ was not declared in this scope; did you mean ‘a3’? 62 | if(aa>=mod1)aa-=mod1; | ^~ | a3 answer.code:63:36: error: ‘bb’ was not declared in this scope; did you mean ‘b3’? 63 | if(bb>=mod2)bb-=mod2; | ^~ | b3 answer.code:64:36: error: ‘bb’ was not declared in this scope; did you mean ‘b3’? 64 | if(bb>=mod2)bb-=mod2; | ^~ | b3 answer.code:65:36: error: ‘bb’ was not declared in this scope; did you mean ‘b3’? 65 | if(bb>=mod2)bb-=mod2; | ^~ | b3 answer.code:66:37: error: ‘aa’ was not declared in this scope; did you mean ‘a3’? 66 | if((aa==0&&bb==0)||(aa==a1&&bb==b1)||(aa==a2&&bb==b2)||(aa==a3&&bb==b3)) | ^~ | a3 answer.code:66:44: error: ‘bb’ was not declared in this scope; did you mean ‘b3’? 66 | if((aa==0&&bb==0)||(aa==a1&&bb==b1)||(aa==a2&&bb==b2)||(aa==a3&&bb==b3)) | ^~ | b3 answer.code:21:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 21 | scanf("%d%d",&n,&k); | ~~~~~^~~~~~~~~~~~~~ answer.code:23:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 23 | scanf("%s",s); | ~~~~~^~~~~~~~