New Contest
Practice
3.8 (6 votes)
Dynamic programming
Combinatorics
Probability and statistics
Easy
Mathematics
Open
Approved
Problem
33% Success 2616 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Our hero - Maga is going to make a new contest for making the best teams. He is really excited about it. There will be S students in the contest. First N students in the final standings will be awarded.

He has a list( favourite students list ) what contains the best students in informatics Olympiad. His favorite students list contains M students. Though he is excited about the contest, he will enjoy it only if at least K of students from his favourite students list are awarded. He is wondering what are the chances of that happening. He needs your help. Tell him the probability that he will enjoy. It is known that each student has equal chance of being awarded.

Input:
First line of input contains a single integer T, the number of test cases. In the next T lines, you are given 4 separated integers, S, N, M and K.

Output:
For each test case, output the required probability with 6 digits after floating point.

Constraints:
1 <= T <= 100
1 <= S <= 1000
1 <= N <= S
1 <= M <= S
0 <= K <= M

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:20
961 votes
Tags:
Dynamic ProgrammingOpenApprovedEasyProbability and Statistics