博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #382 (Div. 2) C. Tennis Championship
阅读量:5280 次
发布时间:2019-06-14

本文共 2409 字,大约阅读时间需要 8 分钟。

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

 

 解题思路:

题目很简单,就是每个人和胜利场次绝对值相差1之内的比,问能比几场,那么a[i]=a[i-1]+a[i-2]。

然后看到大佬的代码。。公式再推一下就成了斐波那契数列再然后:

#include
using namespace std;#define ll long longint main(){ ll m; cin>>m; ll a = 1; ll b = 2,c; int ans = 0; while(1){ if(b>m) break; ans++; c = a + b; a = b; b = c; } cout<
<

心态爆炸,差距太大了。。

转载于:https://www.cnblogs.com/kls123/p/7113517.html

你可能感兴趣的文章
iphone/iOS 访问本地数据库sqlite3
查看>>
关于 ie9 不执行 js 的问题
查看>>
sql 语句之 case
查看>>
二分图行列匹配与最大匹配必须边
查看>>
[设计模式]-对象的封装
查看>>
wpf首次项目开发总结之音频
查看>>
ODBC连接数据库实例
查看>>
HTTP协议中的COOKIE机制简单理解
查看>>
寻找最大值
查看>>
算法提高 日期计算
查看>>
jmeter的web接口测试
查看>>
开发框架模块视频系列(2)-Winform分页控件介绍
查看>>
前端之Java Script(3)
查看>>
函数式编程语言
查看>>
Factorial Trailing Zeroes
查看>>
date_default_timezone_set()设置时区
查看>>
变量的类型自动转换
查看>>
jeecg扩展封装tag的那些事
查看>>
Java课程寒假之开发记账本软件(网页版)之四
查看>>
Spring Boot简明教程之数据访问(一):JDBC Template
查看>>