【Codeforces 735 C Tennis Championship】+ 贪心
来源:互联网 发布:花椒直播mac版 编辑:程序博客网 时间:2024/05/18 16:17
C. Tennis Championship
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
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.
Input
The only line of the input contains a single integer n (2 ≤ n ≤ 1018) — the number of players to participate in the tournament.
Output
Print the maximum number of games in which the winner of the tournament can take part.
Examples
Input
2
Output
1
Input
3
Output
2
Input
4
Output
2
Input
10
Output
4
Note
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.
得分为n的人与得分为n - 1的比赛才能使比赛次数最大化,多少人才能出一个得分为N的人呢?
AC代码:
#include<cstdio>typedef long long LL;int main(){ LL N,l = 1, r = 1,num = 0,t; scanf("%lld",&N); while(l + r <= N) t = l,l = r,r = t + r,num++; printf("%lld\n",num); return 0;}
- 【Codeforces 735 C Tennis Championship】+ 贪心
- codeforces 735c Tennis Championship
- CodeForces 735C Tennis Championship
- codeforces 735 C Tennis Championship
- CodeForces 735C Tennis Championship
- codeforces 735C/382.2.C Tennis Championship
- CodeForces 735C - Tennis Championship(递推)
- Codeforces 735C - Tennis Championship 规律
- codeforces 735 C. Tennis Championship (数学)
- CodeForces 735 C.Tennis Championship(水~)
- Codeforces Round #382 (Div. 2)C. Tennis Championship(贪心)
- 735C Tennis Championship
- Codeforces #382 C Tennis Championship
- codeforces 735C Tennis Championship 思维+递推
- 【17.76%】【codeforces round 382C】Tennis Championship
- Codeforces Round #382 (Div. 2)C. Tennis Championship(贪心) D.巴赫猜想
- Tennis Championship CodeForces
- CF 735C Tennis Championship dp,Fib
- Linux基础-文件权限管理
- 在STM32上创建一个自己的操作系统
- 1029_魔咒词典
- Docker基本操作
- Lock和synchronized比较详解
- 【Codeforces 735 C Tennis Championship】+ 贪心
- 2017-2-5
- Method Swizzling中的陷阱
- [BZOJ2502]清理雪道(有源汇有上下界的最小流)
- 第十一章粒子系统
- Hash table
- 位运算例题2
- 【Maven】maven初步认识
- HDU-2642-Stars(二维树状数组应用)