标签:
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
long long gcd(long long a,long long b,long long &x,long long &y)
{
if(b==0) {
x=1;y=0;
return a;
}
else{
long long d=gcd(b,a%b,x,y);
long long temp=x;
x=y;
y=temp-a/b*y;
return d;
}
}
int main()
{
long long x,y,a,b;
while(cin>>a>>b)
{
long long ans=gcd(a,b,x,y);
if(1%ans)
printf("sorry\n");
else{
while(x<0)
x+=b,y-=a;
printf("%d %d\n",x,y);
}
}
return 0;
}
2015 HUAS Summer Trainning #6~I
标签:
原文地址:http://www.cnblogs.com/chenchunhui/p/4741194.html