Codeforces Round #382 (Div. 1) A. Tennis Championship
来源:互联网 发布:湖北广电网络官网 编辑:程序博客网 时间:2024/05/22 14:02
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.
The only line of the input contains a single integer n (2 ≤ n ≤ 1018) — 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.
2
1
3
2
4
2
10
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.
思路:基本上手推几下就能知道其中的原理然后明白是斐波那契数列。。然后就是一道水题了。
#include<cstdio>#include<algorithm>#include<cstring>#include<iostream>#include<cmath>#include<queue>#include<string>#include<functional>typedef long long LL;using namespace std;#define maxn 105#define ll l,mid,now<<1#define rr mid+1,r,now<<1|1#define lson l1,mid,l2,r2,now<<1#define rson mid+1,r1,l2,r2,now<<1|1#define pi acos(-1.0)#define inf 0x3f3f3f3fconst int mod = 1e9 + 7;int main(){LL a[maxn];a[0] = a[1] = 1;int i = 2, end;while (1){a[i] = a[i - 1] + a[i - 2];if (a[i]>1000000000000000000ll){end = i;break;}i++;}LL n;while (~scanf("%lld", &n)){for (int i = 1; i <= end; i++){if (a[i] > n){printf("%d\n", i - 2);break;}}}}
- Codeforces Round #382 (Div. 1) A. Tennis Championship
- Codeforces Round #382 (Div. 1) A. Tennis Championship(递推)
- Codeforces Round #382 (Div. 1) 736A Tennis Championship
- Codeforces Round #382 (Div. 1) A. Tennis Championship
- Codeforces Round #382 (Div. 2) C - Tennis Championship
- Codeforces Round #382 (Div. 2)C. Tennis Championship(贪心)
- Codeforces Round #382 (Div. 2)-C. Tennis Championship
- Codeforces Round #382 (Div. 2)A到D题 A. Ostap and //B. Urbanization//C. Tennis Championship//D. Taxes
- 【17.76%】【codeforces round 382C】Tennis Championship
- Codeforces Round #382 (Div. 2) C. Tennis Championship 递推、斐波拉契数列
- Codeforces Round #382 (Div. 2) C. Tennis Championship(斐波那契递推)
- Codeforces Round #382 (Div. 2)C. Tennis Championship(递推,斐波那契)
- Codeforces Round #382 (Div. 2)-735C. Tennis Championship(递推)
- Codeforces Round #382 (Div. 2) Tennis Championship (斐波那契)
- Codeforces Round #382 (Div. 2)C. Tennis Championship(贪心) D.巴赫猜想
- Codeforces#382(Div. 2) C.Tennis Championship【递推】
- Codeforces #382 C Tennis Championship
- Codeforces Round #382 (Div. 2) -- C. Tennis Championship (数学找规律 -- 斐波那契数列)
- C计算最大回文字串的长度
- 1225 余数之和
- LlintCode:完美平方
- Linux 安装 .NET Core 1.0 SDK
- 博弈sg函数模板
- Codeforces Round #382 (Div. 1) A. Tennis Championship
- Error: must call SetScrollSizes() or SetScaleToFitSize()问题的解决
- Java获取函数参数名称的几种方法
- 15Spring整合HIbernate&Ibatis(不完整版)
- codeforces 739B B. Alyona and a tree
- AE基础动画参数之制作跳动音符
- Fragment 懒加载
- 线程练习2
- linux中 sed 替换