QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#107071#5301. Modulo Ruins the LegendshihoghmeanWA 6ms4968kbC++141.6kb2023-05-20 10:35:402023-05-20 10:35:44

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-20 10:35:44]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:4968kb
  • [2023-05-20 10:35:40]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int __int128
#define ll long long
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fr(i,a,b) for(int i=a;i>=b;i--)
#define py puts("Yes")
#define pn puts("No")
#define pt puts("")
#define pb push_back
#define wt(x) write(x),puts("")
#define wr(x) write(x) ,putchar(' ')
#define tx printf("fds")
#define mp make_pair
#define fi first
#define se second
inline int read(){
	int x=0,k=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') k=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+ch-48;
		ch=getchar();
	}
	return x*k;
}
void write(int x){
	if(x<0){
		x=-x;
		putchar('-');
	}
	if(x>9) write(x/10);
	putchar(x%10+'0');
}
int power(int x,int y,int mod){
	int num=1;
	while(y){
		if(y&1) num=(num*x)%mod;
		x=x*x%mod;
		y>>=1;
	}
	return num;
}
int mul(int x,int y,int mod){
	int num=0;
	while(y){
		if(y&1) num=(num+x)%mod;
		x=(x+x)%mod;
		y>>=1;
	}
	return num;
}
const int N=1e6+7,mod=998244353;
int n,m,tot,cnt,ans,k;
int a[N],b[N];
char s[N];
int exgcd(int a,int b,int &x,int &y){
	if(b==0){
		x=1;
		y=0;
		return a;
	}
	int g=exgcd(b,a%b,x,y);
	int tmp=x;
	x=y;
	y=tmp-a/b*y;
	return g;
}
signed main(){
	n=read();m=read();
	int x=(1+n)*n/2,y=n,z=0;
	fo(i,1,n) a[i]=read(),z+=a[i];
	int X=0,Y=0;
	int gg=exgcd(x,y,X,Y);
	int ggg=exgcd(gg,m,X,Y);
	k=(m-z)%m;
	k=((k-1)/ggg+1)*ggg;
	wt((k+z)%m);
	int ppp=exgcd(gg,m,X,Y);
	Y=(-Y)*(k/ppp);
	int o=Y*m+k;
	ppp=exgcd(x,y,X,Y);
	X%=m;
	Y%=m;
	X=X*(o/ppp)%m;
	Y=Y*(o/ppp)%m;wr((Y+m)%m);
	wr((X+m)%m);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3316kb

input:

6 24
1 1 4 5 1 4

output:

1
15 3 

result:

ok ok

Test #2:

score: 0
Accepted
time: 2ms
memory: 3480kb

input:

7 29
1 9 1 9 8 1 0

output:

0
0 0 

result:

ok ok

Test #3:

score: 0
Accepted
time: 0ms
memory: 3332kb

input:

1 1
0

output:

0
0 0 

result:

ok ok

Test #4:

score: 0
Accepted
time: 2ms
memory: 3320kb

input:

1 1000000000
963837005

output:

0
36162995 0 

result:

ok ok

Test #5:

score: 0
Accepted
time: 2ms
memory: 3304kb

input:

2 1
0 0

output:

0
0 0 

result:

ok ok

Test #6:

score: 0
Accepted
time: 2ms
memory: 3436kb

input:

2 1000000000
948507269 461613424

output:

0
410120693 589879307 

result:

ok ok

Test #7:

score: 0
Accepted
time: 4ms
memory: 4840kb

input:

100000 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

0
0 0 

result:

ok ok

Test #8:

score: -100
Wrong Answer
time: 6ms
memory: 4968kb

input:

100000 1000000000
253614966 278270960 980235895 498158918 928430170 216003119 852570558 948400590 239257296 897053667 294741176 38297441 382677590 406314557 609468973 854148232 314532767 738191551 158215002 5865825 920471826 380037058 356271728 749175327 28319049 208101105 953758995 896570758 521930...

output:

96613
535900000 999989282 

result:

wrong answer Participant answer greater than judge