标签:while har ++ 最小 扩展欧几里得 lin https exgcd c++
#include<bits/stdc++.h>
#define LL long long
using namespace std;
inline LL read(){
LL s=0,w=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
return s*w;
}
LL exgcd(int a,int b,LL &x,LL &y){
if(b==0){x=1;y=0;return a;}
int d=exgcd(b,a%b,y,x);
y-=x*(a/b);
return d;
}
int main(){
LL a=read(),b=read(),x,y;
exgcd(a,b,x,y);
printf("%lld\n",(x+b)%b);
return 0;
}
标签:while har ++ 最小 扩展欧几里得 lin https exgcd c++
原文地址:https://www.cnblogs.com/PPXppx/p/10500552.html