用gcd解。
//ignore header files
void gcd(long long a,long long b,int &i,int &j,int &d){
if(b == 0){
d = a;
i = 1;
j = 0;
}else{
gcd(b,a%b,j,i,d);
j = j-(a/b)*i;
}
}
int main(int argc, char const* argv[])
{
long long a,b;
while(~scanf("%lld %lld",&a,&b)){
int i,j,d;
gcd(a,b,i,j,d);
printf("%d %d %d\n",i,j,d);
}
return 0;
}