Vampire Dice
Time limit1sMemory limit256 MB
Compute the success probability of scoring at least y points from x exploding ten-sided dice where 8 to 10 score and 10 grants an extra roll.
- Level
Medium5 of 10
- Topics
- Probability, Dynamic programming
- Solved
- No attempts yet
Problem
Vampire is a popular roleplaying game. Like most roleplaying games, Vampire uses dice to settle random events. The most common use of the dice is deciding whether you succeeded or failed at a task. A task might be shooting another player, staying inside a window instead of falling out of it, or dodging an opponent's hit.
The dice used in Vampire are 10-sided, and the rules are these. You may roll dice, and you need or more points to succeed. A die showing 8, 9 or 10 earns one point, so 1 through 7 earn nothing. On top of that, a 10 earns one extra roll. That is why two points or more are possible even when you start with a single die.
Here is an example. Truls tries to avoid falling into a trap. To succeed she has to score 4 or more points on 5 dice. Her first roll gives two 10s, a 4, a 6 and a 3. That is only two points, but the two 10s give her two more dice. This time she rolls a 10 and a 2. She now has three points and one more die. The last die lands on 5, and Truls falls into a big pit and dies.
How large was Truls' chance of surviving in the first place? Write a program that computes the probability of success from the number of dice and the point requirement.
Input
The first line contains the number of cases ().
Each of the next lines contains two integers and , where is the number of dice you start with () and is the number of points needed to succeed ().
Output
For each case, print the probability of success on its own line, rounded to three decimal places and printed with exactly three digits after the decimal point.
No case has a probability that lands exactly on a rounding boundary, so there is no question of which way to break a tie.