## CCC '20 S5 - Josh's Double Bacon Deluxe

View as PDF

Points: 17 (partial)
Time limit: 1.0s
Memory limit: 512M

Author:
Problem types
##### 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?

#### Input Specification

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 Specification

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

0.5

#### Explanation of Output for Sample Input 1

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

0.57142857

• commented on July 9, 2020, 5:29 p.m.

After some calculation I got that for people having distinct burgers, the probability that the last person gets their burger is

Pls check my math.

• commented on Nov. 13, 2021, 4:45 p.m.

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on March 28, 2020, 11:18 a.m.

There are n passengers in a line, waiting to board a plane with n seats. For 1 ≤ k ≤ n, the k th passenger in line has a ticket for the k th seat. However, the first passenger ignores his ticket, and decides to sit in a seat at random. Thereafter, each passenger sits as follows: If his/her assigned is empty, then he/she sits in it. Otherwise, he/she sits in an empty seat at random. How many different ways can all n passengers be seated?

hmmmmm...

• commented on March 13, 2020, 7:25 p.m. edit 2

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on Oct. 21, 2022, 1:38 p.m.

Congratulations on having the comment with the most amount of downvotes on DMOJ!

• commented on Nov. 18, 2022, 12:11 a.m.

thx!

• commented on March 24, 2020, 3:56 a.m. edited

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on March 23, 2020, 6:00 p.m. edited

Were this year's S3 and S4 too stringy as well? And I assume that S2 was much too graphy for your tastes. In my personal opinion, S1 was surely too implementy compared to other S1s.