A8651 | Fibonacci Number
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
John Doe has a list of all Fibonacci numbers modulo $10^{13}$ . This list is infinite, it starts with numbers $0$ and $1$ . Each number in the list, apart from the first two, is a sum of previous two modulo $10^{13}$ . That is, John's list is made from the Fibonacci numbers' list by replacing each number there by the remainder when divided by $10^{13}$ .
John got interested in number $f$ ( $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 $f$ in the list or otherwise state that number $f$ does not occur in the list.
The numeration in John's list starts from zero. There, the $0$ -th position is the number $0$ , the $1$ -st position is the number $1$ , the $2$ -nd position is the number $1$ , the $3$ -rd position is the number $2$ , the $4$ -th position is the number $3$ and so on. Thus, the beginning of the list looks like this: $0,1,1,2,3,5,8,13,21,...$
John got interested in number $f$ ( $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 $f$ in the list or otherwise state that number $f$ does not occur in the list.
The numeration in John's list starts from zero. There, the $0$ -th position is the number $0$ , the $1$ -st position is the number $1$ , the $2$ -nd position is the number $1$ , the $3$ -rd position is the number $2$ , the $4$ -th position is the number $3$ and so on. Thus, the beginning of the list looks like this: $0,1,1,2,3,5,8,13,21,...$
输入格式
The first line contains the single integer $f$ ( $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.
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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted