#P2719. Ticket Type Matching Probability
Ticket Type Matching Probability
Ticket Type Matching Probability
During a quirky World Cup ticket sale, there are 2n tickets in total: n free tickets (A type) and n double-price tickets (B type). The sale process is as follows: for each buyer in line, a fair coin toss decides which type of ticket they should buy. However, if the ticket type determined by the coin toss has already been sold out, the buyer gets the other available ticket instead. This process is equivalent to randomly shuffling the 2n tickets (n of type A and n of type B) and then handing them out in order.
You and your friend are the last two people in line. Later, the ticket seller notices that the remaining two tickets are both free tickets (A type), so no further coin toss is needed for you. Nonetheless, you wonder: What is the probability that the last two people in line receive the same type of ticket (either both A or both B) if the tickets were randomly distributed following the described process?
Hint: Since all ticket assignments are equivalent to a random permutation of n A tickets and n B tickets, the probability that the last two tickets are the same is given by \(\frac{n-1}{2n-1}\).
inputFormat
The input consists of a single line containing an integer n
(where n ≥ 1
), which represents half the total number of tickets. Thus, the total number of tickets is 2n.
outputFormat
Output the probability that the last two tickets are of the same type. The answer must be formatted as a floating point number with exactly 6 decimal places.
sample
1
0.000000