CF193E.Fibonacci Number

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

John Doe has a list of all Fibonacci numbers modulo 101310^{13} . This list is infinite, it starts with numbers 00 and 11 . Each number in the list, apart from the first two, is a sum of previous two modulo 101310^{13} . That is, John's list is made from the Fibonacci numbers' list by replacing each number there by the remainder when divided by 101310^{13} .

John got interested in number ff ( 0<=f<10^{13} ) and now wants to find its first occurrence in the list given above. Help John and find the number of the first occurence of number ff in the list or otherwise state that number ff does not occur in the list.

The numeration in John's list starts from zero. There, the 00 -th position is the number 00 , the 11 -st position is the number 11 , the 22 -nd position is the number 11 , the 33 -rd position is the number 22 , the 44 -th position is the number 33 and so on. Thus, the beginning of the list looks like this: 0,1,1,2,3,5,8,13,21,...0,1,1,2,3,5,8,13,21,...

输入格式

The first line contains the single integer ff ( 0<=f<10^{13} ) — the number, which position in the list we should find.

Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

输出格式

Print a single number — the number of the first occurrence of the given number in John's list. If this number doesn't occur in John's list, print -1.

输入输出样例

  • 输入#1

    13
    

    输出#1

    7
    
  • 输入#2

    377
    

    输出#2

    14
    
首页