CF735C.Tennis Championship

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

著名巴西城市里约热内卢将举办一场网球锦标赛,奥斯塔普·本德尔不想错过这一盛事。共有 nn 名选手参赛,且锦标赛自第一轮起即采用单败淘汰制。这意味着:一旦某位选手输掉一场比赛,便立即被淘汰出局。

主办方仍在安排赛程表(即比赛进行的顺序以及对阵双方的配对),但他们已预先确定了一条规则:两名选手仅当其中一人已参加的比赛场数与另一人已参加的比赛场数之差的绝对值不超过 11 时,方可相互对阵。当然,两位选手均须赢得此前所有比赛,方能继续留在锦标赛中。

目前锦标赛尚未开始,观众略感无聊。奥斯塔普决定弄清:在满足上述规则的前提下,冠军最多可能参加多少场比赛?然而,若无你的帮助,他很可能无法解决这一问题。

输入格式

The only line of the input contains a single integer n (2 ≤ n ≤ 1018) — the number of players to participate in the tournament.

输入仅包含一行,其中有一个整数 nn(2 ≤ n ≤ 10182 \leq n \leq 10^{18}),表示参加比赛的选手人数。

输出格式

Print the maximum number of games in which the winner of the tournament can take part.

输出冠军在该锦标赛中最多能参加的比赛场数。

输入输出样例

  • 输入#1

    2

    输出#1

    1
  • 输入#2

    3

    输出#2

    2
  • 输入#3

    4

    输出#3

    2
  • 输入#4

    10

    输出#4

    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.

在所有样例中,我们均认为编号为 1 的玩家是获胜者。

在第一个样例中,仅进行一场比赛,因此答案为 1。

在第二个样例中,玩家 1 可依次击败玩家 2 和玩家 3。

在第三个样例中,玩家 1 无法与其余每位玩家都比赛:因为当玩家 1 已与玩家 2 和玩家 3 比赛后,便不能再与玩家 4 比赛——此时玩家 4 的已比赛场数为 0,而玩家 1 已比赛 2 场。因此答案为 2;为达到该结果,我们构造配对 (1, 2)(1,\,2) 和 (3, 4)(3,\,4),再让这两场比赛的胜者相互对决。

输入解题思路,AI测评打分。不知道怎么写?

首页