Codeforces Testing Round 3
翻译中…
Let's assume that we have a pair of numbers ($*a*, *b*$). We can get a new pair ($*a* + *b*, *b*$) or ($*a*, *a* + *b*$) from the given pair in a single step.
翻译中…
Let the initial pair of numbers be (1,1). Your task is to find number $*k*$, that is, the least number of steps needed to transform (1,1) into the pair where at least one number equals $*n*$.
翻译中…
Input
翻译中…
The input contains the only integer $*n*$ ($1 ≤ *n* ≤ 10^{6}$).
翻译中…
Output
翻译中…
Print the only integer $*k*$.
翻译中…
Note
翻译中…
The pair (1,1) can be transformed into a pair containing 5 in three moves: (1,1) $→$ (1,2) $→$ (3,2) $→$ (5,2).
翻译中…
样例
Input #1
5
Output #1
3
InputCopy
OutputCopy
Input #2
1
Output #2
0
InputCopy
OutputCopy
题目信息
标签
暴力
DFS 及类似
数学
数论
题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。