[Solution] Madoka and The Corruption Scheme Codeforces Solution
Madoka decided to entrust the organization of a major computer game tournament "OSU"!
In this tournament, matches are held according to the "Olympic system". In other words, there are participants in the tournament, numbered with integers from to . There are rounds in total in the tournament. In the -th round there are matches between two players (one of whom is right, the other is left), after which the winners go further along the tournament grid, and the losing participants are eliminated from the tournament. Herewith, the relative order in the next round does not change. And the winner of the tournament — is the last remaining participant.
But the smaller the participant's number, the more he will pay Madoka if he wins, so Madoka wants the participant with the lowest number to win. To do this, she can arrange the participants in the first round as she likes, and also determine for each match who will win — the participant on the left or right.
But Madoka knows that tournament sponsors can change the winner in matches no more than times. (That is, if the participant on the left won before the change, then the participant on the right will win after the
change, and if the participant on the right won, then the participant on the left will win after the change).
Print the minimum possible number of the winner in the tournament, which Madoka can get regardless of changes in sponsors. But since the answer can be very large, output it modulo . Note that we need to minimize the answer, and only then take it modulo.
The first and the only line contains two integers and () — the number of rounds in the tournament and the number of outcomes that sponsors can change.
Print exactly one integer — the minimum number of the winner modulo
No comments:
Post a Comment