atcoder#ABC297D. [ABC297D] Count Subtractions
[ABC297D] Count Subtractions
Score : points
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 .
- 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.
3 8
4
Initially, and . You repeat the operation as follows:
- BB-A=5A=3B=5$.
- BB-A=2A=3B=2$.
- , so replace with , making and .
- BB-A=1A=1B=1$.
Thus, you repeat it four times.
1234567890 1234567890
0
Note that the input may not fit into a 32-bit integer type.
1597 987
15