Problem D
Delicious Diet for Ducks
Duckies! Valarie loves them so much that she got her own pet duck, which she has called Quackie Chan. Of course, as a mathematician, she wants to optimise Quackie’s happiness: everything from the duck pond, playtime and food choices. But she hasn’t picked out the optimal duck treat yet.
Valarie has done some due diligence, however: She has found $3$ shops selling duck treats nearby, and all of them provide a wide variety of treats. In fact, they are so unique that all the different treats a shop sells aren’t provided by any other shop.
To figure out which of the treats are the best, Valarie is going to let Quackie decide between two different treats every day. The one Quackie prefers is the winner and will be compared with another the next day, until all have been evaluated.
Valarie has given every treat a score from $1$ to $100$, as part of the due diligence. A score of $1$ means she thinks Quackie won’t like it at all, and a score of $100$ means she thinks Quackie will love it.
Because she doesn’t want Quackie to evaluate the treats by ascending or descending score, she has planned to do the following semi-random method of picking the new treat to evaluate against:
She first picks the lowest scoring treat that Quackie hasn’t yet evaluated from each shop. Then she will pick the treat from store $S_ x$ with probability
\[ \cfrac {S_ x}{S_ A + S_ B + S_ C} \]where $S_ A$ is the score for the treat from the first shop, $S_ B$ for the second shop, and $S_ C$ for the last shop.
Of course, this method will break down if all treats from one shop have been evaluated! Valarie knows how to handle that, but she is curious which of the shops will have all their treats evaluated first. Assuming she already has a treat to compare with, can you help her?
Input
The first line contains an integer $A$, the number of treats in the first shop. Then follows a single line with $A$ integers $a_ i$, representing the score of all the unique treats in that shop. This pattern repeats for the remaining two shops, where $B$/$b_ j$ is the second shop, and $C$/$c_ k$ is the last shop.
Output
Output three numbers on three lines: The probability that the first shop will have their treats evaluated first, the probability that the second shop will have their treats evaluated first, and the probability that the last shop will have their treats evaluated first.
All numbers must have a relative or absolute error of at most $10^{-6}$.
Limits
-
$0 < A, B, C \leq 250$
-
$0 < a_ i, b_ j, c_ k \leq 100$, for $0 \leq i < A$, $0 \leq j < B$, $0 \leq k < C$
Sample Input 1 | Sample Output 1 |
---|---|
1 1 1 2 1 3 |
0.16666666666666666 0.33333333333333333 0.5 |
Sample Input 2 | Sample Output 2 |
---|---|
2 1 1 4 1 5 5 5 3 1 2 2 |
0.31676683165958763 0.42124927454905214 0.26198389379136006 |