int exgcd(int a,int b,int &x,int &y) { int d=a; if(b!=0) { d=exgcd(b,a%b,y,x); y-=a/b*x; } else { x=1; y=0; } return d; } int inverse(int a,int m) { int x,y; exgcd(a,m,x,y); return (x%m+m)%m; }
文章来源: https://blog.csdn.net/w1304636468/article/details/90182303