QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#721111#8340. 3 SumAnotherDayofSun#TL 250ms81720kbC++141.5kb2024-11-07 15:17:012024-11-07 15:17:03

Judging History

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

  • [2024-11-07 15:17:03]
  • 评测
  • 测评结果:TL
  • 用时:250ms
  • 内存:81720kb
  • [2024-11-07 15:17:01]
  • 提交

answer

#include<bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#define int long long
using namespace std;
int n,k,a[503][20003],l,c[503][13],ans;
int p[13]={(int)1e9+7,(int)1e9+9,998244353,19260817},e[13],t=4;
char cc[20003];
signed main(){
	scanf("%lld %lld",&n,&k);
	for(int i=1;i<=n;++i){
		scanf("%s",cc);
		l=strlen(cc);
		for(int j=0;j<l;++j){
			a[i][j%k]+=cc[j]-'0';
		}
		for(int j=0;j<k;++j){
			a[i][(j+1)%k]+=a[i][j]/10;
			a[i][j]%=10;
		}
		for(int j=0;j<k;++j){
			a[i][(j+1)%k]+=a[i][j]/10;
			a[i][j]%=10;
		}
	}
	for(int i=0;i<t;++i){
		e[i]=1;
		for(int j=0;j<k;++j){
			e[i]=e[i]*10%p[i];
		}
		--e[i];
		for(int j=1;j<=n;++j){
			c[j][i]=0;
			for(int l=0;l<k;++l){
				c[j][i]=(c[j][i]*10+a[j][l])%p[i];
			}
		}
	}
	for(int i=1;i<=n;++i){
		for(int j=1;j<=i;++j){
			for(int l=1;l<=j;++l){
				bool b=1;
				for(int o=0;o<t;++o){
					if((c[i][o]+c[j][o]+c[l][o])%p[o]!=0){
						b=0;
						break;
					}
				}
				ans+=b;
			}
		}
	}
	for(int i=1;i<=n;++i){
		for(int j=1;j<=i;++j){
			for(int l=1;l<=j;++l){
				bool b=1;
				for(int o=0;o<t;++o){
					if((c[i][o]+c[j][o]+c[l][o])%p[o]!=e[o]){
						b=0;
						break;
					}
				}
				ans+=b;
			}
		}
	}
	for(int i=1;i<=n;++i){
		for(int j=1;j<=i;++j){
			for(int l=1;l<=j;++l){
				bool b=1;
				for(int o=0;o<t;++o){
					if((c[i][o]+c[j][o]+c[l][o])%p[o]!=e[o]*2%p[o]){
						b=0;
						break;
					}
				}
				ans+=b;
			}
		}
	}
	cout<<ans;
}

详细

Test #1:

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

input:

4 1
0
1
10
17

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: 0
Accepted
time: 250ms
memory: 81720kb

input:

500 859
7118711592236878297922359501613604144948355616986970837340677671376753603836852811886591300370143151943368529129749813118476151865844255212534355441611481420938483178075143062691345257288242460282715389758789648541099090735875617822348551942134616963557723055980260082230902505269975518146286...

output:

0

result:

ok 1 number(s): "0"

Test #3:

score: -100
Time Limit Exceeded

input:

500 17336
11871159223687829792235950161360414494835561698697083734067767137675360383685281188659130037014315194336852912974981311847615186584425521253435544161148142093848317807514306269134525728824246028271538975878964854109909073587561782234855194213461696355772305598026008223090250526997551814628...

output:

0

result: