TheTicketsDivOne
SRM 504.5 · 2011-04-28 · by Vasyl[alphacom]
Problem Statement
You are given an
Notes
- The returned value must be accurate to within a relative or absolute value of 1E-9.
Constraints
- n will be between 1 and 1,000, inclusive.
- m will be between 1 and n, inclusive.
2 1 Returns: 0.4444444444444444
John will throw the dice and thus six outcomes are possible: 1: The first friend will go to the end of the line and John will repeat the action. 2: The first friend will go home and John will choose the second friend. 3: The first friend will go to the end of the line and John will repeat the action. 4: John will choose the first friend. 5: The first friend will go to the end of the line and John will repeat the action. 6: The first friend will go home and John will choose the second friend.
2 2 Returns: 0.5555555555555556
1 1 Returns: 1.0
Only one friend here.
3 2 Returns: 0.31746031746031744
25 1 Returns: 0.16776527430800667
Submissions are judged against all 115 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class TheTicketsDivOne with a public method double find(int n, int m) · 115 test cases · 2 s / 256 MB per case