ll kgcd(ll a,ll b,ll &x,ll &y)//扩欧
{
if(!b)
{
x=1;y=0;return a;
}
ll t=kgcd(g,a%b,y,x);
y-=a/b*x;
return t;
}
ll niyuan(ll a,ll p)
{
ll x,y;
kgcd(a,p,x,y);
return (x%p+p)%p;//对x取正
}
转载于:https://www.cnblogs.com/dillydally/p/9567751.html