We heartily thank Artyom Makarov for creating this puzzle!
As it is known, a regular dice has 6
sides, in some cases there can be up to 20
sides, but there exists
another type of dice - one with infinite amount of sides, which means it is perfectly round!
Casting such a dice can give us some real number between 1
and X
.
If we had a few of those dice, we could play a simple game which would require only luck. Let us describe the rules for this game:
N
dice at once and counts the sum of values produced by all of the dice;a
and b
, this player wins. Otherwise, the next player casts the dice;Now, with the rules established, we would like to know the probability for any player to win when they cast the dice.
Input data will containt the number of test cases in the first line.
The following lines will have X
- the maximum value a single dice can yield, then N
- the amount of dice,
and finally values for a
and b
.
Answer should contain probabilities for a player to win when they cast dice for every test case in a single
line separated with spaces. Round them to 3
digits after the dot (trailing zeroes shouldn't matter).
Example
input data:
3
3.03 2778 5570.06 5627.46
3.79 19446 46667.37 46731.93
3.26 175014 372556.99 373273.16
answer:
0.647 0.122 0.758