931B.md (2276B)
1 Source: https://codeforces.com/problemset/problem/931/B 2 3 B. World Cup 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 The last stage of Football World Cup is played using the play-off system. 22 23 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. 24 25 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. 26 27 Input 28 29 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. 30 31 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. 32 33 Output 34 35 In the only line print "Final!" (without quotes), if teams *a* and *b* can meet in the Final. 36 37 Otherwise, print a single integer — the number of the round in which teams *a* and *b* can meet. The round are enumerated from 1. 38 39 Examples 40 41 Input 42 43 ``` 44 4 1 2 45 ``` 46 47 Output 48 49 ``` 50 1 51 ``` 52 53 Input 54 55 ``` 56 8 2 6 57 ``` 58 59 Output 60 61 ``` 62 Final! 63 ``` 64 65 Input 66 67 ``` 68 8 7 5 69 ``` 70 71 Output 72 73 ``` 74 2 75 ``` 76 77 Note 78 79 In the first example teams 1 and 2 meet in the first round. 80 81 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. 82 83 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.