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 ...
随机推荐
- V4L2应用程序框架-二【转】
本文转载自:http://blog.csdn.net/tommy_wxie/article/details/11371439 V4L2驱动框架 主设备号: 81 次设备号: 0-63 64 ...
- JVM学习笔记(一)------基本结构【转】
转自:http://blog.csdn.net/cutesource/article/details/5904501 版权声明:本文为博主原创文章,未经博主允许不得转载. 从Java平台的逻辑结构上来 ...
- GCD 多线程同步
@property (strong, nonatomic) dispatch_queue_t barrierQueue; _barrieQueue = dispatch_queue_create(&q ...
- php socket通信(tcp/udp)
注意 1.在socket_bind的时候ip地址不能真回环地址如127.0.0.1 2.server.php后台跑起来的时候 nohup php server.php > /var/tmp/a. ...
- PG_RMAN备份遇到 domain socket
在用pg_rman做数据全备时:出现异常错误! [postgres@sdserver40_210 run]$ pg_rman backup --backup-mode=full --progress ...
- [ios][swift]Swift - 常用文件目录路径获取(Home目录,文档目录,缓存目录等)
自己写的不一定是最好的! 轮子:http://www.hangge.com/blog/cache/detail_765.html
- sql排序 去除默认升降序排序case方法////遍历数据库所有表及统计表数据总数
case排序法: end 还有EXEC法 可以网上查 SQLServer遍历数据库所有表及统计表数据总数: DECLARE @TableName varchar(); CREATE TABLE #Ge ...
- javascript学习(三) 内置对象
一:事件(Event)对象 在触发dom事件的时候都会产生一个event对象 type 获取事件类型 target 获取事件目标 stopPropagation() 阻止事件冒泡 preven ...
- Linux下c++中的atoi、atol、atoll、atof函数调用实例
本文中调用的四个函数如下: atoi函数:将字符串转化为int类型变量 atol函数:将字符串转化为long类型变量 atoll函数:将字符串转化为long long类型变量 atof函数:将字符串转 ...
- vim中如何替换
1) 文件内全部替换: :%s#abc#123#g (如文件内有#,可用/替换,:%s/abc/123/g) --注:把abc替换成123 (或者: %s/str1/str2/g 用str ...