Problem Statement
While the initial John's intention is to throw a die until some friend is chosen, in practice he gets tired quickly. If after k throws of a die he still hasn't chosen a friend, he prefers to stop the process and to choose the friend who is currently first in line.
You are given an
Definition
- Class:
- TheTicketsDivTwo
- Method:
- find
- Parameters:
- int, int, int
- Returns:
- double
- Method signature:
- double find(int n, int m, int k)
- (be sure your method is public)
Notes
- The returned value must be accurate to within a relative or absolute value of 1E-9.
Constraints
- n will be between 1 and 10, inclusive.
- m will be between 1 and n, inclusive.
- k will be between 1 and 10, inclusive.
Examples
2
1
1
Returns: 0.16666666666666666
There is 1/6 probability that John will choose the first friend after the first throw of a die.
2
1
2
Returns: 0.5833333333333334
The first friend will go to the game if John chooses him after the first throw, or if he goes to the end of the line after the first throw and Jonh doesn't choose the second friend after the second throw. The overall probability is 1/6 + 1/2 * 5/6.
7
7
4
Returns: 0.0
There's no chance for the last friend in the line to be chosen.
4
2
10
Returns: 0.25264033564814814
9
1
4
Returns: 0.16666666666666666
5
5
6
Returns: 0.12152777777777778
1
1
10
Returns: 1.0
10
1
6
Returns: 0.16666666666666666
7
2
6
Returns: 0.1388888888888889
6
3
9
Returns: 0.1586210776748971
4
1
2
Returns: 0.16666666666666666
6
1
7
Returns: 0.20187114197530864
8
2
7
Returns: 0.1388888888888889
2
1
9
Returns: 0.443359375
2
2
3
Returns: 0.625
9
9
9
Returns: 0.0388883530521262
8
6
9
Returns: 0.07633887745770462
7
1
4
Returns: 0.16666666666666666
3
2
9
Returns: 0.3168402777777778
9
7
6
Returns: 0.33489797668038407
6
1
9
Returns: 0.22116126543209877
3
2
10
Returns: 0.3184678819444444
5
1
10
Returns: 0.24895109953703703
7
1
8
Returns: 0.19514639060356653
6
1
9
Returns: 0.22116126543209877
1
1
9
Returns: 1.0
3
3
10
Returns: 0.3439670138888889
7
7
8
Returns: 0.06210348079561043
2
2
10
Returns: 0.5550130208333334
2
1
10
Returns: 0.4449869791666667
9
1
10
Returns: 0.18611084319272977
5
5
10
Returns: 0.16149450231481483
1
1
10
Returns: 1.0
10
1
10
Returns: 0.2635700164005741
7
2
10
Returns: 0.17257962534293553
6
3
10
Returns: 0.1668997556584362
4
1
10
Returns: 0.28313078703703703
6
1
10
Returns: 0.23161008230452676
8
2
10
Returns: 0.16096313085848193
2
1
10
Returns: 0.4449869791666667
3
1
10
Returns: 0.3375651041666667
2
2
10
Returns: 0.5550130208333334
3
3
10
Returns: 0.3439670138888889
2
1
10
Returns: 0.4449869791666667
10
10
10
Returns: 0.03234345429749022
1
1
10
Returns: 1.0
4
1
10
Returns: 0.28313078703703703
10
3
10
Returns: 0.13124527669816594
10
7
10
Returns: 0.05621324556724076
9
8
7
Returns: 0.2790816472336534
10
4
10
Returns: 0.10265243166692069
6
5
4
Returns: 0.48225308641975306
5
4
3
Returns: 0.5787037037037037
3
3
4
Returns: 0.3472222222222222
10
6
10
Returns: 0.06797188563735203
10
8
9
Returns: 0.04651360787227557
10
5
10
Returns: 0.08285624015648022
5
2
3
Returns: 0.1388888888888889
9
2
9
Returns: 0.18540249676116446
4
2
8
Returns: 0.25752314814814814
2
2
1
Returns: 0.8333333333333334
5
1
9
Returns: 0.25636574074074076
7
4
10
Returns: 0.140918370627572
5
2
10
Returns: 0.22075135030864199
9
7
10
Returns: 0.059531464334705075