1771: KnockoutTourney

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:0 解决:0

题目描述

You have just entered a knockout tournament with N competitors. The tournament is structured as follows: at the start, the competitors are written down in a list. Adjacent competitors in the list are then paired off, starting from the first competitor on the list, and each pair plays a match (competitor 1 plays against 2, 3 plays against 4, etc.). The losers of each match are eliminated and their names are crossed off the list, while the winners progress to the next round. If there are an odd number of competitors in a round, then the last competitor in the list advances to the next round automatically, without having to play a match. This process then repeats with the new list of competitors, until only a single competitor remains, who is declared the winner. Note that the ordering of the competitors is preserved between rounds. Your arch-rival has also entered the tournament and you want to know when you might end up playing against him. Your position in the list for the first round is you and your rival‘s position is rival (both indexed from 1). Assuming that both you and your rival win all the matches before you play each other, output the number of the round in which you will meet (counting the rounds from 1).

输入

Each line contains 3 ints, int N, int you, int rival. N will be between 2 and 100000, inclusive. you and rival will each be between 1 and N, inclusive. you and rival will be distinct.

输出

Output the number of the round in which you will meet (counting the rounds from 1)..

样例输入 复制

16 1 2
16 8 9
1000 20 31

样例输出 复制

1
4
4

来源/分类