AtCoder Regular Contest 159
B
GCD Subtraction
AtCoder
⌀ 1438
原题
← AC →
翻译中…

Problem Statement

翻译中…

We have variables $a$ and $b$. Initially, $a=A$ and $b=B$.

翻译中…

Takahashi will repeat the following operation while both $a$ and $b$ are greater than or equal to $1$.

翻译中…
  • Let $g$ be the greatest common divisor of $a$ and $b$, and replace $a$ and $b$ with $a-g$ and $b-g$, respectively.
翻译中…

How many times will he perform the operation?

翻译中…

Constraints

翻译中…
  • $1 \leq A,B \leq 10^{12}$
  • $A$ and $B$ are integers.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

A B

翻译中…

Output

翻译中…

Print the answer.

翻译中…

样例

Input #1
15 9
Output #1
2
We start with $a=15,b=9$ and perform the following. - Let $g=3$, and replace $a$ and $b$ with $12(=15-3)$ and $6(=9-3)$, respectively. - Let $g=6$, and replace $a$ and $b$ with $6(=12-6)$ and $0(=6-6)$, respectively. $b$ is no longer greater than or equal to $1$, so the iteration terminates.
Input #2
1 1
Output #2
1
Input #3
12345678910 10987654321
Output #3
36135
题目信息
题号
arc159_b
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。