#P6708. [CCC 2020] Josh's Double Bacon Deluxe
[CCC 2020] Josh's Double Bacon Deluxe
Background
Josh and other people go to eat burgers.
Problem Description
This burger shop has types of burgers.
Person likes burger type the most.
All people will choose their favorite burger.
Now, these people line up to pick up burgers. Unfortunately, the first person forgets his favorite burger, so he takes a random burger.
The next people will take burgers according to the following rules:
- If his favorite burger is available, he takes it directly.
- Otherwise, he takes a random one.
You need to find the probability that Josh, who is last in line, gets his favorite burger.
Input Format
The first line contains an integer .
The next lines each contain an integer .
Output Format
Output one decimal number, representing the probability that Josh, who is last in line, gets his favorite burger.
3
1 2 3
0.5
7
1 2 3 1 1 2 3
0.57142857
Hint
Explanation for Sample 1
| The first person's choice | The second person's choice | Josh's choice | Probability |
|---|---|---|---|
The probability that Josh gets his favorite burger is .
SPJ Scoring
Let the correct answer be , and your answer be . If , then you get full score for this test point; otherwise, you get .
Subtasks
This problem uses bundled tests, and the Subtask scores have been slightly adjusted.
- Subtask 1 ( points): It is guaranteed that , .
- Subtask 2 ( points): It is guaranteed that .
- Subtask 3 ( points): No special restrictions.
Constraints
For of the testdata, it is guaranteed that , .
Notes
This problem is translated from Canadian Computing Competition 2020 Senior T5 Josh's Double Bacon Deluxe.
Translated by ChatGPT 5