Canadian Computing Competition: 2020 Stage 1, Senior #5
On their way to the contest grounds, Josh, his coach, and his teammates decide to stop at a burger joint that offers distinct burger menu items. After ordering their favourite burgers, the team members line up, with the coach in the first position and Josh last, to pick up their burgers. Unfortunately, the coach forgot what he ordered. He picks a burger at random and walks away. The other team members, in sequence, pick up their favourite burger if available, or a random remaining burger if there are no more of their favourite burger. What is the probability that Josh, being last in line, will get to eat his favourite burger?
The first line contains the number , the total number of people and burgers. The next line contains numbers, the -th being , denoting the item number of the -th person’s favourite burger. The first person in line is the coach, and the -th person is Josh.
For of the available marks, and .
For an additional of the available marks, .
Output a single number , the probability that Josh will get to eat his favourite burger, . If the correct answer is , the grader will view correct if .
Sample Input 1
3 1 2 3
Output for Sample Input 1
Explanation of Output for Sample Input
The coach randomly chooses between the three burgers. With probability , he chooses his favourite burger (burger 1), and Josh gets to eat his favourite burger (burger ). With probability , he chooses Josh's favourite burger, and Josh fails to eat his favourite burger. With probability , he chooses the second person's burger, there is a chance that the second person chooses Josh's burger, denying Josh the pleasure of eating his favourite burger.
Sample Input 2
7 1 2 3 1 1 2 3
Output for Sample Input 2