Problem6012--扩展欧几里得算法

6012: 扩展欧几里得算法

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 256 MiB

Description

给定 $n$ 对正整数 $a_i,\ b_i$,对于每对数,求出一组 $x_i,\ y_i$,使其满足 $a_i×x_i+b_i×y_i=\text{gcd}(a_i,\ b_i)$。

Input

第一行包含整数 $n\ (1 \leq n \leq 10^5)$。
接下来 $n$ 行,每行包含两个整数 $a_i,\ b_i\ (1 \leq a_i,\ b_i \leq 2 \times 10^9)$。

Output

输出共 $n$ 行,对于每组 $a_i,\ b_i$,求出一组满足条件的 $x_i,\ y_i$,每组结果占一行。
本题答案不唯一,输出任意满足条件的 $x_i,\ y_i$ 均可。

Sample 1 Input

2
4 6
8 18

Sample 1 Output

-1 1
-2 1

Source/Category

数学 10.5.裴蜀定理