Codeforces Round #382 (Div. 2) C. Tennis Championship 斐波那契
2 seconds
256 megabytes
standard input
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.
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.
题意:给你n个人,一个人有一个比赛次数,输了就淘汰,每个人能跟比赛次数相差不超过1的比赛,问一个赢的人最多比几次;
思路:显然4需要跟3比才能得到5,相当于n-1需要跟n-2比得到n,不就是一个菲薄那契么,暴力求解就好了;
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define esp 0.00000000001
const int N=1e5+,M=1e6+,inf=1e9;
const ll INF=1e18+;
ll a[];
int main()
{
a[]=;
a[]=;
for(int i=;i<=;i++)
a[i]=a[i-]+a[i-];
ll x;
scanf("%lld",&x);
for(int i=;i>=;i--)
if(x>=a[i])
{
printf("%d\n",i);
return ;
}
return ;
}
Codeforces Round #382 (Div. 2) C. Tennis Championship 斐波那契的更多相关文章
- Codeforces Round #382 (Div. 2) C. Tennis Championship
C. Tennis Championship time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- Codeforces Round #382 (Div. 2)C. Tennis Championship 动态规划
C. Tennis Championship 题目链接 http://codeforces.com/contest/735/problem/C 题面 Famous Brazil city Rio de ...
- codeforces Codeforces Round #597 (Div. 2) Constanze's Machine 斐波拉契数列的应用
#include<bits/stdc++.h> using namespace std; ]; ]; ; int main() { dp[] = ; scanf(); ); ; i< ...
- Codeforces Round #382 Div. 2【数论】
C. Tennis Championship(递推,斐波那契) 题意:n个人比赛,淘汰制,要求进行比赛双方的胜场数之差小于等于1.问冠军最多能打多少场比赛.题解:因为n太大,感觉是个构造.写写小数据, ...
- Codeforces Round #382 (Div. 2) (模拟|数学)
题目链接: A:Ostap and Grasshopper B:Urbanization C:Tennis Championship D:Taxes 分析:这场第一二题模拟,三四题数学题 A. 直接模 ...
- Codeforces Round #382 (Div. 2) 继续python作死 含树形DP
A - Ostap and Grasshopper zz题能不能跳到 每次只能跳K步 不能跳到# 问能不能T-G 随便跳跳就可以了 第一次居然跳越界0.0 傻子哦 WA1 n,k = map ...
- Codeforces Round #382 (Div. 2) D. Taxes 哥德巴赫猜想
D. Taxes 题目链接 http://codeforces.com/contest/735/problem/D 题面 Mr. Funt now lives in a country with a ...
- Codeforces Round #382 (Div. 2)B. Urbanization 贪心
B. Urbanization 题目链接 http://codeforces.com/contest/735/problem/B 题面 Local authorities have heard a l ...
- Codeforces Round #283 (Div. 2) D. Tennis Game(模拟)
D. Tennis Game time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...
随机推荐
- Java汉诺塔算法
汉诺塔问题[又称河内塔]是印度的一个古老的传说. 据传开天辟地之神勃拉玛在一个庙里留下了三根金刚石的棒,第一根上面套着64个圆的金片,最大的一个在底下,其余一个比一个小,依次叠上去,庙里的众僧不倦地把 ...
- linux设备驱动归纳总结(七):1.时间管理与内核延时【转】
本文转载自:http://blog.chinaunix.net/uid-25014876-id-100005.html linux设备驱动归纳总结(七):1.时间管理与内核延时 xxxxxxxxxxx ...
- 前端开发自动化工作流工具,JavaScript自动化构建工具grunt、gulp、webpack介绍
前端开发自动化工作流工具,JavaScript自动化构建工具grunt.gulp.webpack介绍 前端自动化,这样的一个名词听起来非常的有吸引力,向往力.当今时代,前端工程师需要维护的代码变得及为 ...
- Ubuntu 下配置ftp服务端
安装sudo apt-get install pure-ftpdsudo netstat –ano | grep “21”查看21端口是否已开启.完成安装后,就可以用Ubuntu系统的用户名和密码登陆 ...
- tr DEMO
测试数据: [weblogic@etp-mall-dev7][/tmp]$ cat msn.txt aaa bbb bbb ccc ccc ddd bbb eee aaa ccc bbb sss 转换 ...
- Hive文件格式
hive文件存储格式包括以下几类: 1.TEXTFILE 2.SEQUENCEFILE 3.RCFILE 4.ORCFILE(0.11以后出现) 其中TEXTFILE为默认格式,建表时不指定默认为这个 ...
- require()与 require_once()、 include与include_once()
- ACM题目————数素数
令Pi表示第i个素数.现任给两个正整数M <= N <= 104,请输出PM到PN的所有素数. 输入格式: 输入在一行中给出M和N,其间以空格分隔. 输出格式: 输出从PM到PN的所有素数 ...
- JQuery知识快览之五—操作属性和结构
前文提到JQuery提供了丰富的内置方法来操作对象集,本文主要介绍JQuery中的那些内置操作属性和DOM结构的方法. prop还是attr? 从JQuery1.6版开始,新增了prop方法来获取和设 ...
- 哈希-4 Values whose Sum is 0 分类: POJ 哈希 2015-08-07 09:51 3人阅读 评论(0) 收藏
4 Values whose Sum is 0 Time Limit: 15000MS Memory Limit: 228000K Total Submissions: 17875 Accepted: ...