A10762 | Tennis Championship
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Famous Brazil city Rio de Janeiro holds a tennis tournament and Ostap Bender doesn't want to miss this event. There will be $n$ players participating, and the tournament will follow knockout rules from the very first game. That means, that if someone loses a game he leaves the tournament immediately.
Organizers are still arranging tournament grid (i.e. the order games will happen and who is going to play with whom) but they have already fixed one rule: two players can play against each other only if the number of games one of them has already played differs by no more than one from the number of games the other one has already played. Of course, both players had to win all their games in order to continue participating in the tournament.
Tournament hasn't started yet so the audience is a bit bored. Ostap decided to find out what is the maximum number of games the winner of the tournament can take part in (assuming the rule above is used). However, it is unlikely he can deal with this problem without your help.
Organizers are still arranging tournament grid (i.e. the order games will happen and who is going to play with whom) but they have already fixed one rule: two players can play against each other only if the number of games one of them has already played differs by no more than one from the number of games the other one has already played. Of course, both players had to win all their games in order to continue participating in the tournament.
Tournament hasn't started yet so the audience is a bit bored. Ostap decided to find out what is the maximum number of games the winner of the tournament can take part in (assuming the rule above is used). However, it is unlikely he can deal with this problem without your help.
输入格式
The only line of the input contains a single integer $n$ ( $2<=n<=10^{18}$ ) — the number of players to participate in the tournament.
输出格式
Print the maximum number of games in which the winner of the tournament can take part.
输入输出样例
输入 #1
2
输出 #1
1
输入 #2
3
输出 #2
2
输入 #3
4
输出 #3
2
输入 #4
10
输出 #4
4
In all samples we consider that player number $1$ is the winner.
In the first sample, there would be only one game so the answer is $1$ .
In the second sample, player $1$ can consequently beat players $2$ and $3$ .
In the third sample, player $1$ can't play with each other player as after he plays with players $2$ and $3$ he can't play against player $4$ , as he has $0$ games played, while player $1$ already played $2$ . Thus, the answer is $2$ and to achieve we make pairs $(1,2)$ and $(3,4)$ and then clash the winners.
In the first sample, there would be only one game so the answer is $1$ .
In the second sample, player $1$ can consequently beat players $2$ and $3$ .
In the third sample, player $1$ can't play with each other player as after he plays with players $2$ and $3$ he can't play against player $4$ , as he has $0$ games played, while player $1$ already played $2$ . Thus, the answer is $2$ and to achieve we make pairs $(1,2)$ and $(3,4)$ and then clash the winners.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted