#P5415. Final Winner Prediction
Final Winner Prediction
Final Winner Prediction
After a long and mind‐bending journey, your brain has been thoroughly exercised! Now, for the grand finale of our adventure, we play a game. There are \(n\) people, uniquely numbered from \(1\) to \(n\). The game is played in rounds as follows:
- Before the game begins, all \(n\) participants are queued in order from \(1\) to \(n\).
- In each round, only 4 people are allowed to play. The first 4 people from the waiting queue form the contestants for this round.
- In the round, each contestant has an equal probability of winning. The winner will remain in the game for the next round and his current consecutive win count increases by 1. The losers will leave the round and be appended to the end of the waiting queue. However, when appending, the order among losers is decided as follows: among all losers of the current round, those who have ever won in any previous round (i.e. at least one win before) are placed before those who have never won; within each group the original order (the order at the beginning of the round) is preserved.
- In the next round, the new game contestants are: the previous round's winner (who carries his consecutive win count) and the first 3 people from the waiting queue. (Note that when a player loses, his consecutive win count is reset to 0, but his record of having won at least once is preserved for ordering purposes.)
- If any contestant wins \(m\) consecutive rounds (i.e. his win streak becomes \(m\)), he is declared the final winner and the game ends immediately.
Your task is to calculate the probability that the person with original number \(k\) is the final winner.
Input: Three integers \(n\), \(m\), and \(k\) where \(n \ge 4\). It is guaranteed that the game will have a result.
Note on formulas: All formulas are in \(\LaTeX\) format. For example, the condition for winning is: if a contestant's consecutive win count reaches \(m\), i.e. if \(\text{streak} = m\), then he wins.
inputFormat
The input consists of a single line with three space‐separated integers:
- \(n\): the total number of players
- \(m\): the number of consecutive wins required to win the game
- \(k\): the original number of the player whose probability of ultimately winning is to be computed
outputFormat
Output a floating–point number representing the probability that the \(k^{th}\) person is the final winner. The answer should be accurate up to at least 6 decimal places.
sample
4 1 1
0.250000