CF134B.Pairs of Numbers

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

重题请做P2090

输入格式

Let's assume that we have a pair of numbers ( a,ba,b ). We can get a new pair ( a+b,ba+b,b ) or ( a,a+ba,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 kk , that is, the least number of steps needed to transform (1,1) into the pair where at least one number equals nn .

输出格式

The input contains the only integer nn ( 1<=n<=1061<=n<=10^{6} ).

输入输出样例

  • 输入#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).

首页