QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#499292#8340. 3 SumxqbfRE 0ms0kbC++141.8kb2024-07-31 11:30:092024-07-31 11:30:09

Judging History

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

  • [2024-09-20 10:20:30]
  • hack成功,自动添加数据
  • (/hack/848)
  • [2024-07-31 11:30:09]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-07-31 11:30:09]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=505,maxk=20005;
int n,k,a[maxn][maxk],p[15]={998244353,1000000007,1019344367,1000000009,19260817},len[maxn],p1[maxk],p2[maxk],p3[maxk];
string s;
int b[maxn][15],prime=5;
int resm[15],resm2[15];
signed main(){
	freopen("M.in","r",stdin);
	freopen("M.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>s;
		for(int j=0;j<s.size();j++){
			a[i][s.size()-j-1]=s[j]-'0';
		}
		len[i]=s.size();
		while(len[i]>k){
			for(int j=0;j<k;j++){
				p1[j]=a[i][j];
			}
			for(int j=k;j<len[i];j++){
				p2[j-k]=a[i][j];
			}
			int len1=k,len2=len[i]-k,carry=0;
			for(int j=len1;j<len[i];j++)p1[j]=0;
			for(int j=len2;j<len[i];j++)p2[j]=0;
			for(int j=0;j<max(len1,len2);j++){
				int tmp=(p1[j]+p2[j]+carry)%10;
				carry=(p1[j]+p2[j]+carry)/10;
				a[i][j]=tmp;
			}
			len[i]=max(len1,len2);
			if(carry!=0)a[i][len[i]++]=carry;
		}
	}
	//for(int i=1;i<=n;i++)printf("%lld\n",a[i][0]);
	for(int v=0;v<prime;v++){
		resm[v]=0;resm2[v]=0;
		for(int i=0;i<k;i++){
			resm[v]=(resm[v]*10+9)%p[v];
		}
		resm2[v]=(resm[v]+resm[v])%p[v];
		for(int i=1;i<=n;i++){
			for(int j=len[i]-1;j>=0;j--){
				b[i][v]=(b[i][v]*10+a[i][j])%p[v];
			}	
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		for(int j=i;j<=n;j++){
			for(int k=j;k<=n;k++){
				int flag0=1,flag1=1,flag2=1;
				for(int v=0;v<3;v++){
					int tmp=(b[i][v]+b[j][v]+b[k][v])%p[v];
					if(tmp!=0){
						flag0=0;
					}
					if(tmp!=resm[v]){
						flag1=0;
					}
					if(tmp!=resm2[v]){
						flag2=0;
					}
					if((flag0==0)&&(flag1==0)&&(flag2==0)){
						break;
					}
				}
				if((flag0==0)&&(flag1==0)&&(flag2==0));
				else{ans++;}
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

详细

Test #1:

score: 0
Dangerous Syscalls

input:

4 1
0
1
10
17

output:


result: