Dice
Time limit1sMemory limit128 MB
Given n and k, find the number of ways n fair dice can sum to k, then output the integer part of 100 times that probability.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Combinatorics, Math, Probability
- Solved
- No attempts yet
Problem
Jack claims that he has telekinetic powers. He has bet Mike that he can throw a die times and make the pips add up to exactly . Jack's die is a perfectly symmetric cube with the numbers through on its faces. Mike does not believe in telekinesis, but he is worried that Jack might win the bet by pure luck. He therefore wants to know the chance (as a percentage) of such an unlucky event, and asks you to write a program that computes it.
In other words, throw a fair die times and find, as a percentage, the probability that the pips add up to exactly .
Input
The first line contains a single integer (), the number of test cases. Each of the next lines contains two integers and () separated by a single space, where is the number of throws and is the target sum of pips.
Output
For each test case, print on its own line the probability (as a percentage) that Jack wins the bet, rounded down to the nearest integer. That is, print the integer part of times the probability that throws of a fair die sum to exactly .