Codeforces Round #382 (Div. 1) 736A Tennis Championship【找规律】

题目传送门: 点击打开链接
A. 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 ben 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 playeddiffers 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 players2 and 3.

In the third sample, player 1 can't play with each other player as after he plays with players2 and 3 he can't play against player4, as he has 0 games played, while player1 already played 2. Thus, the answer is2 and to achieve we make pairs (1, 2) and (3, 4) and then clash the winners.


题意:n个人在一起打网球比赛,两个人对打。一个人如果输了,就要退出比赛。两个人可以打比赛有个前提条件:两个人的比赛场数的差值不能大于1。问这n个人中打了最多比赛的那个人打了几场比赛。


这题其实就是要自己画个表来找规律。

 2=1 3=2 4=2 5=3 6=3 7=3 8=4 9=4 10=4 11=4 12=4 13=5 14=5 15=5 16=5 17=5 18=5
19=5 20=5 21=6 22=6 23=6 24=6 25=6 26=6 27=6 28=6 29=6 30=6 31=6 32=6 33=6  34=7 35=7 36=7 37=7 38=7 39=7 40=7 41=7 42=7 43=7 44=7 45=7 46=7 47=7 48=7  49=7 50=7 51=7 52=7 53=7 54=7 55=8 56=8 57=8 58=8 59=8 60=8 61=8 62=8 63=8  64=8 65=8 66=8 67=8 68=8 69=8 70=8 71=8 72=8 73=8 74=8 75=8 76=8 77=8 78=8  79=8 80=8 81=8 82=8 83=8 84=8 85=8 86=8 87=8 88=8 89=9 90=9 91=9 92=9


仔细观察节点的话会发现数列是酱紫的:1,2,3,5,8,13........

嗯,没错,这就是个递归数列。。是斐波那契数列。找到规律的话,直接上代码:

#include<bits/stdc++.h>
using namespace std;
#define LL long long
LL fib[205];
void FF()
{
    fib[0]=0;
    fib[1]=1;
    for(int i=2;i<=200;i++)
    {
        fib[i]=fib[i-1]+fib[i-2];
    }
}

int main()
{
    FF();
    LL n;
    while(~scanf("%lld",&n))
    {
        for(int i=0;i<200;i++)
        {
            if(fib[i]>n)
            {
                printf("%d\n",i-3);
                break;
            }
        }
    }
    return 0;
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值