exgcd
1 ll exgcd(ll a,ll b,ll &x,ll &y) 2 { 3 if(b==0) 4 { 5 x=1;y=0;return a; 6 } 7 ll r=exgcd(b,a%b,x,y); 8 ll t=x; 9 x=y; 10 y=t-a/b*y; 11 return r; 12 }
1 ll exgcd(ll a,ll b,ll &x,ll &y) 2 { 3 if(b==0) 4 { 5 x=1;y=0;return a; 6 } 7 ll r=exgcd(b,a%b,x,y); 8 ll t=x; 9 x=y; 10 y=t-a/b*y; 11 return r; 12 }