Chandu and Probability
Practice
4 (1 votes)
Dynamic programming
Probability and statistics
Medium
Mathematics
Open
Approved
Problem
19% Success 326 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

After playing the game of stones and board chandu decide to put all the games in the boxes and sleep. But, he is afraid that you will go to market without taking him along with you. So, he decide to indulge you in a task.

Clever chandu has N boxes, N keys and N locks (1 key corresponding to each lock). He put all locks on all the boxes. Shuffled all the keys that are with him and slipped them into the box(Those were piggy bank like boxes).

Now, obviously, No one will be able to any of his box not even him without keys. But he has prepared a few bombs which can be used to break the locks. One bomb can be used to break exactly one lock. He asks you what is the probability that he will be able to open all boxes if he has M bombs.

Input:

First line of input contains t which is the number of test cases. Each test case contains exactly one line having 2 integers N and M.

Output:

Print the probability that he will be able to open all boxes in a/b format. Note that a/b is in minimal fraction form.

Constraints:

\(1 \le N \le 20\),

\(1 \le M \le N\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
Tags:
MathematicsMediumOpenApprovedProbability and Statistics