#abc297d. D - Count Subtractions
D - Count Subtractions
Score : points
问题描述
你已知两个正整数 和 。
你需要重复以下操作,直到 :
- 比较 和 ,执行以下两种操作之一:
- 若 ,则用 替换 ;
- 若 ,则用 替换 。
请问需要重复多少次才能使得 ?可以保证有限次的重复操作后,一定能使得 。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given positive integers and .
You will repeat the following operation until :
- compare and to perform one of the following two:
- if , replace with ;
- if , replace with .
How many times will you repeat it until ? It is guaranteed that a finite repetition makes .
Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
3 8
Sample Output 1
4
Initially, and . You repeat the operation as follows:
- , so replace with , making and .
- , so replace with , making and .
- , so replace with , making and .
- , so replace with , making and .
Thus, you repeat it four times.
Sample Input 2
1234567890 1234567890
Sample Output 2
0
Note that the input may not fit into a 32-bit integer type.
Sample Input 3
1597 987
Sample Output 3
15
update @ 2024/3/10 12:20:29