CF931B.World Cup

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

The last stage of Football World Cup is played using the play-off system.

There are n teams left in this stage, they are enumerated from 1 to n. Several rounds are held, in each round the remaining teams are sorted in the order of their ids, then the first in this order plays with the second, the third — with the fourth, the fifth — with the sixth, and so on. It is guaranteed that in each round there is even number of teams. The winner of each game advances to the next round, the loser is eliminated from the tournament, there are no draws. In the last round there is the only game with two remaining teams: the round is called the Final, the winner is called the champion, and the tournament is over.

Arkady wants his two favorite teams to play in the Final. Unfortunately, the team ids are already determined, and it may happen that it is impossible for teams to meet in the Final, because they are to meet in some earlier stage, if they are strong enough. Determine, in which round the teams with ids a and b can meet.

世界杯足球赛的最后阶段采用淘汰赛制。

此阶段共剩余 nn 支球队,编号为 11 至 nn。比赛分为若干轮进行:在每一轮中,将当前剩余的球队按其编号升序排列,然后排在第 11 位的球队与第 22 位的球队比赛,第 33 位与第 44 位比赛,第 55 位与第 66 位比赛,依此类推。保证每轮参赛球队数均为偶数。每场比赛的胜者晋级下一轮,败者被淘汰,且不存在平局。最后一轮仅剩两支球队进行一场比赛,该轮称为“决赛”,获胜者即为冠军,整个锦标赛结束。

阿尔卡季希望他最喜爱的两支球队能在决赛中相遇。但遗憾的是,各队编号已经确定,而这两支队伍可能因实力足够强而在更早的轮次中提前相遇,从而无法抵达决赛。请判断编号为 aa 和 bb 的两支球队最早可能在哪一轮相遇。

输入格式

The only line contains three integers n, a and b (2 ≤ n ≤ 256, 1 ≤ a, b ≤ n) — the total number of teams, and the ids of the teams that Arkady is interested in.

It is guaranteed that n is such that in each round an even number of team advance, and that a and b are not equal.

唯一一行包含三个整数 nn、aa 和 bb(2 ≤ n ≤ 2562 \leq n \leq 256,1 ≤ a, b ≤ n1 \leq a, b \leq n)——分别表示队伍总数,以及 Arkady 关心的两支队伍的编号。

保证 nn 满足:每一轮中均有偶数支队伍晋级;且 a≠ba \neq b。

输出格式

In the only line print "Final!" (without quotes), if teams a and b can meet in the Final.

Otherwise, print a single integer — the number of the round in which teams a and b can meet. The round are enumerated from 1.

在唯一的一行中输出 "Final!"(不带引号),如果队伍 a 和 b 可以在决赛中相遇。

否则,输出一个整数——即队伍 a 和 b 可能相遇的轮次编号。轮次从 1 开始编号。

输入输出样例

  • 输入#1

    4 1 2

    输出#1

    1
  • 输入#2

    8 2 6

    输出#2

    Final!
  • 输入#3

    8 7 5

    输出#3

    2

说明/提示

In the first example teams 1 and 2 meet in the first round.

In the second example teams 2 and 6 can only meet in the third round, which is the Final, if they win all their opponents in earlier rounds.

In the third example the teams with ids 7 and 5 can meet in the second round, if they win their opponents in the first round.

在第一个例子中,队伍 1 和队伍 2 在第一轮相遇。

在第二个例子中,队伍 2 和队伍 6 只有在赢得之前所有轮次的对手后,才能在第三轮(即决赛)中相遇。

在第三个例子中,编号为 7 和 5 的队伍若在第一轮中击败各自对手,则可在第二轮相遇。

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

首页