View Code
int N,M;//注意题目说x为正整数,0不算int Extend_euc(int a,int b,int&x,int&y) { if(b==0) {x=1,y=0;return a;} int d=Extend_euc(b,a%b,x,y); int tmp=x; x=y; y=tmp-(a/b)*y; return d;}void modeq(int a,int b,int n) { int e,i,d,x,y,tmp; d=Extend_euc(a,n,x,y); if(b%d>0) puts("Not Exist"); else { e=((x*(b/d))%n+n)%n; printf("%d\n",e); }}void get_data() { int i,j,k; scanf("%d%d",&N,&M);}void solve() { int i,j,k; if(M==1) puts("1"); else modeq(N,1,M);}