Problem8979--HDU3076 - ssworld VS DDD

8979: HDU3076 - ssworld VS DDD

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 512 MiB

Description

One day, sssworld and DDD play games together, but there are some special rules in this games.
They both have their own HP. Each round they dice respectively and get the points $P_1, P_2\ (1 \leq P_1, P_2 \leq 6)$. Small number who, whose HP to reduce $1$, the same points will remain unchanged. If one of them becomes $0$ HP, he loses.
As a result of technical differences between the two, each person has different probability of throwing 1, 2, 3, 4, 5, 6. So we couldn’t predict who the final winner.

Input

There are multiple test cases.
For each case, the first line are two integer $HP_1, HP_2\ (1 \leq HP_1, HP_2 \leq 2,000)$, said the first player sssworld’s HP and the second player DDD’s HP.
The next two lines each have six floating-point numbers per line. The $j$-th number on the $i$-th line means the the probability of the $i$-th player gets point $j$. 
The input data ensures that the game always has an end.

Output

One float with six digits after point, indicate the probability sssworld won the game.

Sample 1 Input

5 5
1.000 0.000 0.000 0.000 0.000 0.000
0.000 0.000 0.000 0.000 0.000 1.000
5 5
0.000 0.000 0.000 0.000 0.000 1.000
1.000 0.000 0.000 0.000 0.000 0.000

Sample 1 Output

0.000000
1.000000

HINT

相同题目:HDU 3076

Source/Category

概率DP