Time limit
2s
Memory limit
128 MB
A tournament has 8 participants and is played over 3 rounds.
In round 1, match i is played between participant 2 × i and participant 2 × i + 1 (0 ≤ i ≤ 3). The 4 winners advance to round 2.
In round 2, the winner of round-1 match 2 × i plays the winner of round-1 match 2 × i + 1 (0 ≤ i ≤ 1). The 2 winners advance to round 3.
In round 3, the two round-2 winners play each other to decide the tournament winner.
Given every head-to-head win probability among the 8 participants, compute the probability that each participant wins the tournament.
The first line contains 28 integers. The first 7 values are the probabilities that participant 0 beats participants 1 through 7, respectively. The next 6 values are the probabilities that participant 1 beats participants 2 through 7, respectively. The remaining values continue in the same order: for each lower-numbered participant, the probabilities of beating each higher-numbered participant are given in increasing opponent order. Every value is an integer.
Print one line containing the probability that each participant from 0 through 7 wins the tournament, separated by spaces. An absolute or relative error of at most 10^-9 is accepted.