luogu#P3764. 签到题 III
签到题 III
Background
The Junior contestant zzq recently learned the Euclidean algorithm for computing the greatest common divisor (GCD).
Problem Description
By analogy with the Euclidean algorithm, zzq defined a strange function:
typedef long long ll;
ll f(ll a,ll b)
{
if(a==b) return 0;
if(a>b) return f(a-b,b+b)+1;
else return f(a+a,b-a)+1;
}
After defining this function, zzq excitedly entered two numbers to compute the value of , but found that the function fell into an infinite recursion... Therefore, zzq defines the value of to be in cases where the recursion would loop infinitely.
Now zzq inputs a number , and wants to compute .
Input Format
One line containing an integer .
Output Format
One line containing an integer .
100
1124
2000
68204
Hint
For 10% of the testdata, .
For 40% of the testdata, .
For 70% of the testdata, .
For 100% of the testdata, .
Translated by ChatGPT 5