bool CRT(int a1,int m1,int a2,int m2,int &a,int &m) { int x,y; int d = exgcd(m1,m2,x,y); int z = a2-a1; if(z%d) return 0; x = (int)(1LL*x*(z/d)%(m2/d)); m=int(1LL*m1*m2/d); a = int((1LL*a1+1LL*x*m1%m+m)%m); return 1;}
本文共 296 字,大约阅读时间需要 1 分钟。
bool CRT(int a1,int m1,int a2,int m2,int &a,int &m) { int x,y; int d = exgcd(m1,m2,x,y); int z = a2-a1; if(z%d) return 0; x = (int)(1LL*x*(z/d)%(m2/d)); m=int(1LL*m1*m2/d); a = int((1LL*a1+1LL*x*m1%m+m)%m); return 1;}
转载于:https://www.cnblogs.com/Syameimaru/p/11048737.html