National Football League
All submissions for this problem are available.
As a BITS - Pilani student and a football player, Bayne was delighted once he heard the news, BITS-Pilani is finally participating in the National Football League (NFL).
A team is to be formed of "n" players, all of which are BITS students. However, the team might have players belonging to different departments. There are "m" departments in BITS, numbered from 1 to m. Bane's department has number "h". For each department "i", Bane knows number s[i] — how many students who play football belong to this department.
Bane was also able to guarantee a spot on the team, using his special powers. But since he hates floating-point numbers, he needs your help at finding the probability that he will have at least one teammate belonging to his department.
Note that every possible team containing Bane is equally probable. Consider all the students different from each other.
- The first line of the input contains three integers n, m and h denoting the number of players on the team, the number of departments in BITS and Bane's department, correspondingly.
- The second line contains a single-space-separated list of m integers si (1 ≤ s[i] ≤ 100), denoting the number of students in the i-th department. Note that s[h] includes Bane
- Print the probability that Bane will have at least one teammate from his department. If there is not enough football players in BITS to participate in NFL, print "-1"(without quotes).
The ans should be rounded off to 6 decimal places i.e. should contain maximum 6 digits after decimal point.
For eg. In C++ you can use setprecision(6), and in c : printf("%0.6lf") .
- 1 ≤ n ≤100
- 1 ≤ m ≤1000
- 1 ≤ h ≤m
Input: 3 2 1 2 1 Output:
|Tags||dynamic-programming, f2012086, icl2015, maths|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA|
Fetching successful submissions