Sports Loans

View as PDF

Submit solution

Points: 100 (partial)
Time limit: 1.0s
Memory limit: 20M

Problem type
Allowed languages
C#, C++, Go, Haskell, Java, JS, Python, Rust, Text

Andrew is head of the sports club, and manages the inventory. Part of Andrew's job is loaning footballs to people, and collecting those footballs once they have been used.

At the start of the day, Andrew has r footballs in stock, and knows that p+q people will approach him over the course of the day. p people will request a football, while q people will return a football. What Andrew does not know is the order in which these people will approach him.

Of course, Andrew wants to be able to give a football to everyone who requests one, when they request one. So for example if the first r+1 people want a football, Andrew can't give a football to the last person.

Andrew wants to know the probability that the above situation does not occur today, in other words the probability that every time someone requests a football, Andrew has one in stock.

Input / Output

Input will consist of three space separated integers, p, q and r, as defined in the problem statement. (r \leq 20. p and q can be large.) Output should be a single number, the probability that Andrew will always be able to give a football to anyone who requests it.

Example Test


4 1 3



There is a 20% chance the "return a football" event occurs after all 4 "request a football" events, which would cause a problem.


The answer should have absolute error less than 10^{-8}. An answer with absolute error less than 10^{-4} will score half of the available points. Anything more innaccurate will not get any points.


There are no comments at the moment.