Euclid problem

2020年1月17日 845点热度 0人点赞 0条评论

Euclid problem

时间: 1ms        内存:64M

描述:

From Euclid, it is known that for any positive integers A and B there exist such integers X and Y that AX + BY = D, where D is the greatest common divisor of A and B. The problem is to find the corresponding X, Y, and D for a given A and B.

输入:

The input will consist of a set of lines with the integer numbers A and B, separated with space ( A, B < 1, 000, 000, 001).

输出:

For each input line the output line should consist of three integers X, Y, and D, separated with space. If there are several such X and Y, you should output that pair for which X<=Y and | X| + | Y| is minimal.

示例输入:

4 6
17 17

示例输出:

-1 1 2
0 1 17

提示:

参考答案:

解锁文章

没有看到答案?微信扫描二维码可免费解锁文章

微信扫描二维码解锁

使用微信扫描二维码打开广告页面后可以立即关闭,再刷新此页面即可正常浏览此文章

所跳转广告均由第三方提供,并不代表本站观点!

已经扫描此二维码?点此立即跳转

code

这个人很懒,什么都没留下

文章评论