Description
A △△ game competition is now being held. In this competition, N players participate and the game proceeds as a tournament. N participants are given a number from 1 through N. Then, participants of number 1↔number 2, number 3↔number 4, ... , number N-1↔number N play a game. The winner of each match proceeds to the next round. The participants to move on to the next round will receive a new number from 1 through N/2. If participant number 2 wins in the game between participant number 1↔participant number 2, the number 1 is given. Similarly, if participant number 3 wins in the game between participant number 3↔participant number 4, the number 2 is given. The competition will continue until the last participant remains.
In the first round, a participant number A
wonders which round he will play with the participant number B
, who is regarded as his rival. Given the number of participants N
, the first number given to participant A
, and the first number given to participant B
as parameters, write a function solution to return which round participant number A
will play a game with his rival, participant number B
. Assume that participants number A
and B
will always win until they meet.
Constraints
N
: a natural number between 21 and 220 (Since it is given as an exponential of 2, there are no default wins).A
,B
: natural number less than or equal toN
(However, A ≠ B).
Examples
N | A | B | answer |
---|---|---|---|
8 | 4 | 7 | 3 |
Example #1
In the first round, participant number 4 plays a game with participant number 3 and participant number 7 plays a game with participant number 8. Since we assume that participant number 4 and number 7 always wins, participant number 4 and number 7 receive number 2 and number 4 at the next round, respectively. In the second round, participant number 2 plays a game with participant number 1 and participant number 4 plays a game with participant number 3. Similarly, participant number 2 and number 4 is given the number 1 and 2 in the next round, respectively. Since these participants play a game as participant number 1 and number 2 in the third round, return 3.
베타 기간 동안에는 한 문제당 1번만 물어볼 수 있어요.