Problem I
First Orchard

First Orchard is a cooperative game for children 2 years and up. In this simple game, the players pick colored fruits from trees in an orchard and place them into a basket. To make the game more interesting, a raven tries to reach the orchard to steal the fruits. If the players are successful in moving all fruits into the basket before the raven can get to the orchard, they’ll win. If the raven gets there first, the players lose!
Your task is to determine the probability with which the players will win!
The game is played as follows. There are
At each turn, the players roll a six-sided die. Four of the faces show a color (red, green, yellow, blue), the fifth face shows a fruit basket, and the sixth face shows a raven. All six faces can appear with equal probability.
-
Red, Green, Yellow, Blue. In these cases, a fruit with the corresponding color is placed into the basket, provided the tree corresponding to this color still has any fruits left to pick. Otherwise, the players move on to the next turn.
-
Fruit Basket. If the players roll the ’basket’ face, they will pick a fruit from the tree that has the largest number of fruits left. If there are multiple such trees with the same number of fruits, any of the trees can be chosen.
-
Raven. If the ’raven’ face appears on the die, then the raven moves one step closer towards the orchard.
The game is over if either the players have picked all fruits, or if the raven reaches the orchard, whichever happens first. If the raven reaches the orchard before the players have placed all fruits into the basket, the players lose.
Input
The input consists of a single test case with a single line
of input. The input contains five integer numbers:
Output
Output the probability that the players will win as a
floating point number. The absolute error of your result should
be less than
Sample Input 1 | Sample Output 1 |
---|---|
1 1 0 0 3 |
0.920138888889 |
Sample Input 2 | Sample Output 2 |
---|---|
4 4 4 4 5 |
0.631357306601 |
Sample Input 3 | Sample Output 3 |
---|---|
4 4 4 4 4 |
0.459393713591 |