ALGOR Contest: Round #3 (Weekly Sprint)
Problem B · 100 points ·
ICPC rules
~/algor $ cat contests/round-3/B
B. Euclidean algorithm steps
1000 ms
64 MB
Two positive integers $a$ and $b$ are given. In the Euclidean algorithm, at each step the pair $(a, b)$ is replaced by the pair $(b, a \bmod b)$; when $b = 0$, $a$ is the GCD of the original numbers. Find the GCD and the number of steps the algorithm performs.
Input
One line with two positive integers: $a$ and $b$.
Output
Two integers separated by a space: the GCD and the number of steps.
Note
$1 \le a, b \le 10^{18}$
Examples
Input #1
48 18
Output #1
6 3
Input #2
7 7
Output #2
7 1