#P6997. Ticket Distribution Probability
Ticket Distribution Probability
Ticket Distribution Probability
Dmitry loves programming competitions, and he is excited to attend the Champions League Finals being held in his hometown. However, most tickets are reserved for VIPs and sponsors, and the general public must obtain tickets through a lottery system. In this lottery, there are n available seats. Several drawing rounds are conducted. In each round, every unfulfilled request is assigned a number of slots based on the chosen payment method: 2 slots for users of the ICPC card (sponsor of the event) and 1 slot for users of any other method.
In every round, one slot is selected uniformly at random and the corresponding request is fulfilled. The draw continues for n rounds or until there are no more unfulfilled requests, whichever comes first.
Dmitry holds both an ICPC card and an ACM card, but he can use only one method per ticket application. His brother Petr has informed him beforehand how many people have already chosen to use the ICPC card (p) and how many are using other methods (q). By adding Dmitry's request to these, you are to help him determine:
- The probability that his request is fulfilled if he uses his ICPC card (which gives him 2 slots per round).
- The probability that his request is fulfilled if he uses his ACM card (which gives him 1 slot per round).
If the total number of requests (including Dmitry's) is less than or equal to n, then every request is fulfilled and the probability is 1. Otherwise, let:
\(W =\) total number of slots in a round (with pre-existing requests contributing 2 slots each for ICPC users and 1 slot each for other methods, plus Dmitry’s slots depending on his card choice), and \(w\) be the number of slots Dmitry receives (either 2 or 1). Let \(r=\min(n, p+q+1)\) be the number of rounds (or fulfilled requests) distributed. Then the probability that Dmitry is never selected in any round is:
\[ \prod_{i=0}^{r-1}\frac{W-w-i}{W-i} \]
Thus, the probability that Dmitry's request is fulfilled is:
\[ P = 1 - \prod_{i=0}^{r-1}\frac{W-w-i}{W-i} \]
inputFormat
The input consists of three space-separated integers:
- n — the number of available seats.
- p — the number of pre-existing requests using the ICPC card.
- q — the number of pre-existing requests using other payment methods.
outputFormat
Output two floating-point numbers separated by a space:
- The first number is the probability that Dmitry gets a ticket if he uses his ICPC card.
- The second number is the probability if he uses his ACM card.
Print the probabilities with at least 6 decimal places of precision.
sample
1 1 1
0.400000 0.250000
</p>