1 条题解
-
12230134娄耀 (2212238) LV 8 @ 2023-06-03 12:48:24
#include<bits/stdc++.h> using namespace std; int a,b,x,y; int exgcd(int a,int b,int &x,int &y) { if(b==0) { x=1;y=0; return a; } int ret=exgcd(b,a%b,x,y); int buf=x;x=y;y=buf-a/b*y; return ret; } int main() { cin>>a>>b; int gcd=exgcd(a,b,x,y); x=(x%b+b)%b; cout<<x; return 0; }
- 1