#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
const int maxm = 100005;
int exgcd(int a, int b, int &x, int &y)
{
if (b == 0)
{
x = 1, y = 0;
return a;
}
int ans = exgcd(b, a%b, x, y);
int temp = x;
x = y;
y = temp - (a / b)*y;
return ans;
}
int main()
{ cin.tie(0);
ios::sync_with_stdio(0);
int n, i, j, k, sum, a, b, x, y;
while (scanf("%d%d", &a, &b) != EOF)
{
k = exgcd(a, b, x, y);
printf("%d %d %d\n", k, x, y);
}
return 0;
}
©著作权归作者所有:来自51CTO博客作者qinXpeng的原创作品,如需转载,请注明出处,否则将追究法律责任