QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#606957#5301. Modulo Ruins the Legend999#WA 0ms3948kbC++14756b2024-10-03 13:14:222024-10-03 13:14:24

Judging History

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

  • [2024-10-03 13:14:24]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3948kb
  • [2024-10-03 13:14:22]
  • 提交

answer

#include<bits/stdc++.h>
#define For(a,b,c) for(int a=b;a<=c;++a)
using namespace std;
int n,m,s,tt;
int gcd(int a,int b) {
	return b?gcd(b,a%b):a;
}
int x,y,t,g;
void god(int a,int b){
	if(b==0)x=1,y=0,g=a;
	else{
		god(b,a%b);
		t=x;x=y;
		y=t-a/b*y;
	}
}
int f(int a,int b,int m){
	god(a,m);
	b/=g;
	x=(1ll*x*b)%(m/g);
	assert((a*x%m+m)%m==(b*g+m)%m);
	return x;
}
int cook(int x) {
	g=gcd(n,m);
	int c=(m-x+g-1)/g;
	int y=(x+c*g)%m;
	tt=(f(n,(y-x+m)%m,m)%m+m)%m;
	return y;
}
int main(){
	scanf("%d%d",&n,&m);
	For(i,1,n) {
		int x; scanf("%d",&x);
		(s+=x)%=m;
	}
	int dd=(1LL*n*(n-1)/2)%m;
	int a=cook((s+dd)%m);
	int b=cook(s);
	if(a<b) cook((s+dd)%m),printf("%d\n%d 1",a,tt);
	else printf("%d\n%d 0",b,tt);
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3948kb

input:

6 24
1 1 4 5 1 4

output:

1
3 1

result:

wrong answer Result not equal to solution.