Time Limit: 2000MS Memory Limit: 65536 K
The game of tennis has a rather unusual scoring system. It can be simplified
to the following rule: "If a player has at least four points, and is at
least two points ahead of his opponent, that player wins the game."
For example, 4-1 and 6-4 are winning scores, whereas 3-0 and 5-4 are not.
We can generalize this class of point systems by introducing two variables,
N and M. The new rule is "If a player has at least N points,
and is at least M points ahead of his opponent, that player wins the game."
For example, the common practice of taking "best two out of three"
falls into this class, where N = 2 and M = 1.
You would like to know, given a particular point system and the skills of
two players, the probability of an upset. An "upset" is defined as a game
where a player of lesser skill beats a player of greater skill.
Given an int S, representing the percent likelihood that the worse player
beats the better player on any particular turn, along with N and M,
you should output a double between 0 and 1 indicating the odds of an upset.
The first line of input is the number of test case.
The only one line of each test case contains three integers N M and S.
There is a blank line before each test case.
( 1 <= N <= 10 , 1 <= M <= 5 , 1 <= S <= 50 )
For each test case output the answer on a single line.
The result should be rounded to six decimal places.
2 1 40
3 3 25
The first case of the sample is the 'best two out of three' game. There are
exactly three possible ways for an upset to occur:
1) The worse player scores two consecutive points, with probability 0.4*0.4 = 0.16
2) The better player scores one point, and then the worse player scores two
consecutive points, with probability 0.6*0.4*0.4 = 0.096
3) The worse player scores one point, the better player scores one point, and then
finally the worse player a second point, with probability 0.4*0.6*0.4 = 0.096
Thus, the total probability is 0.16+0.096+0.096 = 0.352