代码:
1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 5 long long exgcd(long long a,long long b,long long& x,long long& y) 6 { 7 if(b==0) 8 { 9 x=1,y=0; 10 return a; 11 } 12 long long g = exgcd(b,a%b,y,x); 13 y -= a/b*x; 14 return g; 15 } 16 17 int main() 18 { 19 long long m,n,x1,y1; 20 while(cin >> m >> n) 21 { 22 if (exgcd(m,n,x1,y1) != 1) 23 printf("sorry "); 24 else 25 { 26 while(x1< 0) 27 { 28 x1+= n; 29 y1-= m; 30 } 31 printf("%I64d %I64d ",x1,y1); 32 } 33 } 34 return 0; 35 }