QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#606957 | #5301. Modulo Ruins the Legend | 999# | WA | 0ms | 3948kb | C++14 | 756b | 2024-10-03 13:14:22 | 2024-10-03 13:14:24 |
Judging History
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.