~/algor $ cat problems/while-ekub-ayirish-usulida
GCD by subtraction
Easy
1000 ms
64 MB
32%
Two positive integers $a$ and $b$ are given. While the numbers are not equal, the smaller one is subtracted from the larger one:
$$a \gt b \Rightarrow a = a - b, \qquad b \gt a \Rightarrow b = b - a$$
When the numbers become equal, their value is the greatest common divisor (GCD) of $a$ and $b$. Find the GCD and the number of subtractions performed (for example, $(12; 18) \to (12; 6) \to (6; 6)$: GCD $6$, $2$ subtractions).
Input
One line with two positive integers: $a$ and $b$.
Output
One line with two integers separated by a space: the GCD and the number of subtractions.
Note
$1 \le a, b \le 10^{6}$
Examples
Input #1
12 18
Output #1
6 2
Input #2
7 7
Output #2
7 0