Logo
(追記) (追記ここまで)

19610번 - Josh’s Double Bacon Deluxe 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB47221846.154%

문제

On their way to the contest grounds, Josh, his coach, and his N − 2 teammates decide to stop at a burger joint that offers M 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 N (3 ≤ N ≤ 1 000 000), the total number of people and burgers. The next line contains N numbers, the i-th being bi (1 ≤ bi ≤ M ≤ 500 000), denoting the item number of the i-th person’s favourite burger. The first person in line is the coach, and the N-th person is Josh.

출력

Output a single number P, the probability that Josh will get to eat his favourite burger, bN. If the correct answer is C, the grader will view P correct if |P − C| < 10−6.

제한

예제 입력 1

3
1 2 3

예제 출력 1

0.5

The coach randomly chooses between the three burgers. With probability 1/3, he chooses his favourite burger (burger 1), and Josh gets to eat his favourite burger (burger 3). With probability 1/3, he chooses Josh’s favourite burger, and Josh fails to eat his favourite burger. With probability 1/3, he chooses the second person’s burger, there is a 1/2 chance that the second person chooses Josh’s burger, denying Josh the pleasure of eating his favourite burger.

예제 입력 2

7
1 2 3 1 1 2 3

예제 출력 2

0.57142857

힌트

출처

Olympiad > Canadian Computing Competition & Olympiad > 2020 > CCC 2020 Senior Division 5번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /