cswork / OA打开练习工作台

XperiOA #2

Make Numbers Equal

简单可在线判题

考点(AI 标注)位运算

There are two positive integers A and B, and you need to make A and B equal through some operations. In each operation: if A is greater than B, then A=A−B; if B is greater than A, then B=B−A. Each operation costs 1. Find the total cost to make A equal to B.

输入格式

One line with two space-separated integers A and B. 1≤A,B≤10^18.

输出格式

Output one integer, the total cost.

样例 1

输入:

7 9

输出:

5

样例 2

输入:

4 4

输出:

0

样例 3

输入:

12 3

输出:

3

样例说明

Example 1: A=7, B=9. B=9−7=2, A=7−2=5, A=5−2=3, A=3−2=1, B=2−1=1, for 5 operations in total. Example 2: A and B are equal from the start, so the cost is 0. Example 3: 12→9→6→3, for 3 operations in total.