Dice with Infinity Sides

Problem #379

Tags: mathematics c-1 puzzle

Who solved this?

No translations... yet

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:

  1. There can be an infinite amount of players (although, it is not important for this problem);
  2. Each player casts N dice at once and counts the sum of values produced by all of the dice;
  3. If this sum fits in range between a and b, this player wins. Otherwise, the next player casts the dice;
  4. The game continues until any of the players wins.

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
You need to login to get test data and submit solution.