exgcd

int exgcd(int a,int b,int &x,int &y)
{
    if(b==0)
    {
        x=1,y=0;
        return a;
    }
    else
    {
        int d=exgcd(b,a%b,y,x);
        y-=a/b*x;
        return d;
    }
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325729325&siteId=291194637