A11636 | World Cup
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
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.
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.
输出格式
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$ .
Otherwise, print a single integer — the number of the round in which teams $a$ and $b$ can meet. The round are enumerated from $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.
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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted