萌新求助,本地 AC,提交 CE
查看原帖
萌新求助,本地 AC,提交 CE
610335
lemon_qwq楼主2023/8/8 14:04

rt,本地 devc++ 是可以运行的,提交发现编译失败。

如何解决,98 和 14 都试过了。

#include<bits/stdc++.h>
#define int __int128
using namespace std;
int exgcd(int a,int b,int &x,int &y,int c){
	if(b==0){
		x=c/a;
		y=0;
		return a;
	}
	int g=exgcd(b,a%b,y,x,c);
	y-=a/b*x;
	return g;
}
void excrt(int &A,int &P,int a,int p){
	int x=0,y=0;
	int g=abs(exgcd(p,-P,x,y,A-a));
	P=p/g*P;
	A=a+x*p;
	A=(A%P+P)%P;
}
int n,A,P,a,p;
signed main(){
	scanf("%lld",&n);
	scanf("%lld%lld",&P,&A);
	for(int i=2;i<=n;i++){
		scanf("%lld%lld",&p,&a);
		excrt(A,P,a,p);
	}
	cout<<(long long)((A%P+P)%P)<<endl;
	return 0;
}
2023/8/8 14:04
加载中...