#P2238. Computer Basketball Game

Computer Basketball Game

Description

In a computer basketball game, people can play "one vs. one", which has the following rules: when a player attacks, he may throw 2-point-goal or 3-point-goal. If he makes the goal, he can continue to attack in the next turn. Otherwise, i.e. he misses the goal, the two players grab the rebound, and who gets the rebound attack in the next turn. The player who first gets N (1 <= N <= 30) points will win the game.

In this game, each player has four kinds of properties: the skill of 2-point-goal, the skill of 3-point-goal, the skill of rebound and the skill of defense. (Each skill is described in integers between 1 and 10). Through the statistic data, we can know the functions of skill. We use pt2(i), pt3(i), reb(i) and def(i) to represent the skill of 2-point-goal, the skill of 3-point-goal, the skill of rebound and the skill of defense of player i respectively. Take the case that player 1 attacks while player 2 defends for example, we will have the following conclusion: 1. The probability that player 1 chooses to throw 3-point-goal is pt3(1)/[pt3(1)+pt2(1)], otherwise he throws 2-point-goal. 2. If player 1 throws 3-point-goal, the probability that he makes the goal is 0.8*pt3(1)/[pt3(1)+def(2)], otherwise he misses the goal. 3. If player 1 throws 2-point-goal, the probability that he makes the goal is pt2(1)/[pt2(1)+def(2)], otherwise he misses the goal. 4. If player 1 misses a goal, the probability that he can get the rebound is 0.8*reb(1)/[reb(1)+reb(2)], otherwise player 2 get the rebound.

The case that player 2 attacks while player 1 defends is similar to the description above.

Well, now you are given the skill of your opponent, and you can assign your four kinds of skill in any way, but the sum of these four numbers must be a certain number M (4 <= M <= 40). Assume that you attack first, the problem is what is the maximum probability you win the game by assigning the skill optimally. You should know that once you choose your skills, the skills are fixed in every turn.

Input

The input consists of several test cases. In each test case, there are six integers N, M, pt2(2), pt3(2), reb(2), def(2) in a single line. (Assume you are player 1, and your opponent is player2.)

Output

For each test case, please output the result in a separate line. The result should be rounded to three digits after the decimal point.

19 21 3 5 6 6
0.754

Hint

NOTICE:the winner can get N or more than N points,not just N points.

Source

POJ Monthly

,鲁小石