CF134B.Pairs of Numbers
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
假设我们有一对数字 (a,b)。在一步操作中,我们可以从给定的数对得到新数对 (a+b,b) 或 (a,a+b)。
设初始数对为 (1,1)。你的任务是求出数字 k,即从 (1,1) 出发,经过最少多少步操作后,能得到一个至少有一个数等于 n 的数对。
输入格式
The input contains the only integer n (1 ≤ n ≤ 106).
输入仅包含一个整数 n(1 ≤ n ≤ 106)。
输出格式
Print the only integer k.
输出唯一的整数 k。
输入输出样例
输入#1
5
输出#1
3
输入#2
1
输出#2
0
说明/提示
The pair (1,1) can be transformed into a pair containing 5 in three moves: (1,1) → (1,2) → (3,2) → (5,2).
数对 (1,1) 可以通过三步变换得到一个包含 5 的数对:(1,1)→(1,2)→(3,2)→(5,2)。
输入解题思路,AI测评打分。不知道怎么写?