405840: GYM102134 A Tennis
Description
Software engineer Andrew is keen on sports, especially tennis. Andrew is not perfect player, hence sometimes he wins and sometimes he loses. Obviously, all lost matches make him very angry and hence make his primary work less efficient. Therefore, Andrew has made a conclusion "I will be less angry, if I don't take part in such matches". So he has decided to win all the times. This is very straightforward to compute the probability to win whole match knowing p1 and p2 – probabilities of winning a point, when you are serving and not serving, respectively. Andrew is taking part in a very important match soon. Could you please help him to compute the probability to win this game?
Tennis rules.
Match consists of sets, which are divided to games. The serving person is the same in each game. To win a game player should score at least 4 points, but his competitor should have at least two points less. The serving person is changed after each game. To win a set player should win 6 (6-0, 6-1, 6-2, 6-3, 6-4) or 7 games (7-5). Otherwise, if the score is 6-6, the referee announces tiebreak.
Tiebreak rules.
The person, who has not served last game, should serve first. After first played point serving person is changed. Then the serving person is changed after each two played points. To win tiebreak player should score at least 7 points and his competitor should score at least two points less. The winner of tiebreak wins the set.
To win a match player should win 3 sets. In case of tiebreak a serving person in next set should be a player who has not served during the first serve. Otherwise, the person who has not serve during last game should serve in the next set.
InputA single line contains two real numbers p1 and p2 — probabilities of winning a point, when you are serving and not serving, respectively. The maximum number of digits after decimal point is 4.
0 ≤ p1, p2 ≤ 1
OutputA single line should contain the probability of winning the whole match. The absolute and relative error of given answer should not exceed 10 - 9.
ExamplesInput0.5 0.5Output
0.500000000000000Input
0.7 0.3Output
0.500000000000000Note
Andrew always serves in the first game of the first set.