QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#588568#5301. Modulo Ruins the Legendlouhao088#WA 0ms3776kbC++231.0kb2024-09-25 13:18:552024-09-25 13:18:56

Judging History

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

  • [2024-09-25 13:18:56]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3776kb
  • [2024-09-25 13:18:55]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

const int maxn=1e5+5;
inline int read(){
	char ch=getchar();bool f=0;int x=0;
	for(;!isdigit(ch);ch=getchar())if(ch=='-')f=1;
	for(;isdigit(ch);ch=getchar())x=(x<<1)+(x<<3)+(ch^48);
	if(f==1)x=-x;return x;
}
inline void print(int x){
    static int a[55];int top=0;
    if(x<0) putchar('-'),x=-x;
    do{a[top++]=x%10,x/=10;}while(x);
    while(top) putchar(a[--top]+48);
}
int n,m,A,B,C,x,y;
int exgcd(int a,int b){
	if(!b) {x=1,y=0;return a;}
	int res=exgcd(b,a%b);
    int t=x;x=y,y=t-a/b*y;
    return res;
}
int main()
{
	n=read(),m=read();
    for(int i=1;i<=n;i++) {C+=read(); if(C>=m) C-=m;}
 	A=n%m,B=((1ll*n*(n-1))>>1)%m;
    int s,t,p,q;
    p=exgcd(A,m),s=(x%m+m)%m;
    q=exgcd(B,m),t=(x%m+m)%m;
    int r=exgcd(p,q);
    x=(x%m+m)%m,y=(y%m+m)%m;
    s=1ll*s*x%m,t=1ll*t*y%m;
    int d=C/r;
    s-=1ll*d*x%m; if(s<0) s+=m;
    t-=1ll*d*y%m; if(t<0) t+=m;
    printf("%d\n",C%r);
    printf("%d %d\n",s,t);
    return 0;
}


详细

Test #1:

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

input:

6 24
1 1 4 5 1 4

output:

1
0 16

result:

wrong answer Result not equal to solution.