Joy
Time limit2sMemory limit512 MB
Given a queue of n-1 players and your skill x, find for each of the n insertion positions the probability that you win the knockout tournament.
- Level
Hard8 of 10
- Topics
- Divide and conquer, Dynamic programming, Probability
- Solved
- No attempts yet
Problem
Suppose other people with skill levels are standing in a queue for a rock paper scissors tournament, and your skill level is . You insert yourself into one of the positions in the queue: before person 1, between person 1 and person 2, and so on, up to after person . For each position, find the probability that you win the tournament.
The tournament runs as follows. While the queue has at least two people, pop the two people at the front and have them play a match. If players with skill levels and play, the first one wins with probability and the second one wins with probability . There are no draws.
The winner goes to the back of the queue, and the loser is eliminated. The last person standing is the winner of the tournament.
Input
The first line contains two integers and (, for an integer , ).
The second line contains integers (). is the skill level of the person at the front of the queue, and is the skill level of the person at the back.
Output
For each of the positions in the queue, from front to back, print the probability that you win the tournament, one per line. Answers with an absolute or relative error of at most are accepted.
Hint
In the first test case, you beat any opponent with probability . To win the tournament, you must beat two opponents, so the answer is regardless of your starting position.