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个人,一个人有一个比赛次数,输了就淘汰,每个人能跟比赛次数相差不超过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 斐波那契的更多相关文章

  1. 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 ...

  2. Codeforces Round #382 (Div. 2)C. Tennis Championship 动态规划

    C. Tennis Championship 题目链接 http://codeforces.com/contest/735/problem/C 题面 Famous Brazil city Rio de ...

  3. codeforces Codeforces Round #597 (Div. 2) Constanze's Machine 斐波拉契数列的应用

    #include<bits/stdc++.h> using namespace std; ]; ]; ; int main() { dp[] = ; scanf(); ); ; i< ...

  4. Codeforces Round #382 Div. 2【数论】

    C. Tennis Championship(递推,斐波那契) 题意:n个人比赛,淘汰制,要求进行比赛双方的胜场数之差小于等于1.问冠军最多能打多少场比赛.题解:因为n太大,感觉是个构造.写写小数据, ...

  5. Codeforces Round #382 (Div. 2) (模拟|数学)

    题目链接: A:Ostap and Grasshopper B:Urbanization C:Tennis Championship D:Taxes 分析:这场第一二题模拟,三四题数学题 A. 直接模 ...

  6. Codeforces Round #382 (Div. 2) 继续python作死 含树形DP

    A - Ostap and Grasshopper zz题能不能跳到  每次只能跳K步 不能跳到# 问能不能T-G  随便跳跳就可以了  第一次居然跳越界0.0  傻子哦  WA1 n,k = map ...

  7. 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 ...

  8. Codeforces Round #382 (Div. 2)B. Urbanization 贪心

    B. Urbanization 题目链接 http://codeforces.com/contest/735/problem/B 题面 Local authorities have heard a l ...

  9. 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 ...

随机推荐

  1. IT书籍的选择与阅读

    拍摄是一件艰苦而有趣的事情. 它需要眼睛和心灵完全融合投入, 需要耐心等待排除干扰, 需要敏捷捕捉稍纵即逝的瞬间. 但是, 非艰苦不成乐趣. 人生也应该选择一件有难度的事情来做. 做不成, 可以收获过 ...

  2. java总结第二次//数组及面向对象

    三.java数组 主要内容:数组概述.一维数组声明.数组元素的引用.数组元素的默认初始化.创建数组.数组初始化.多维数组.多维数组初始化.数组排序 1.数组概述 数组是多个相同类型数据的组合,实现对这 ...

  3. linux设备驱动归纳总结(十三):1.触摸屏与ADC时钟【转】

    本文转载自:http://blog.chinaunix.net/uid-25014876-id-119723.html linux设备驱动归纳总结(十三):1.触摸屏与ADC时钟 xxxxxxxxxx ...

  4. 【python cookbook】【数据结构与算法】13.通过公共键对字典列表排序

    问题:想根据一个或多个字典中的值来对列表排序 解决方案:利用operator模块中的itemgetter()函数对这类结构进行排序是非常简单的. # Sort a list of a dicts on ...

  5. JVM学习笔记(一)------基本结构【转】

    转自:http://blog.csdn.net/cutesource/article/details/5904501 版权声明:本文为博主原创文章,未经博主允许不得转载. 从Java平台的逻辑结构上来 ...

  6. javascript 金额格式化

    金额格式化 example: <!DOCTYPE html> <html> <head> <script src="http://code.jque ...

  7. 八大排序算法之六--交换排序—快速排序(Quick Sort)

    基本思想: 1)选择一个基准元素,通常选择第一个元素或者最后一个元素, 2)通过一趟排序讲待排序的记录分割成独立的两部分,其中一部分记录的元素值均比基准元素值小.另一部分记录的 元素值比基准值大. 3 ...

  8. windows上安装apache python mod_python

    综述:   windows上安装apache python mod_python的例子.教程甚至图解都不少:但作为新手还是会出错,而且一时无法快速排解. 在此笔者将根据自己的实践经验,给出几个需要注意 ...

  9. vc6

    适合win7使用的: http://pan.baidu.com/s/1nt7SG57

  10. 分页sql

    /// <summary> /// 根据页数分页 /// </summary> /// <param name="page"></para ...