아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Birthday Paradox

시간 제한2초메모리 제한1024 MB

요약
각 생일을 공유하는 사람 수가 주어질 때, P명 중 그 분포가 나타날 확률을 계산해 상용로그 값을 출력한다.
난이도

보통10점 중 4점

유형
확률, 조합론, 수학
정답자
아직 제출이 없습니다

문제

The Birthday Paradox is the name given to the surprising fact that if there are just 2323 people in a group, there is a greater than 5050\\% chance that a pair of them share the same birthday. The underlying assumptions for this are that all birthdays are equally likely (which isn't quite true), the year has exactly 365365 days (which also isn't true), and the people in the group are uniformly randomly selected (which is a somewhat strange premise).  For this problem, we'll accept these assumptions.

Consider what we might observe if we randomly select groups of P=10P=10 people. Once we have chosen a group, we break them up into subgroups based on shared birthdays. Among many other possibilities, we might observe the following distributions of shared birthdays:

  • all 1010 have different birthdays, or
  • all 1010 have the same birthday, or
  • 33 people have the same birthday, 22 other people have the same birthday (on a different day), and the remaining 55 all have different birthdays.

Of course, these distributions have different probabilities of occurring.

Your job is to calculate this probability for a given distribution of people sharing birthdays.  That is, if there are PP people in a group, how probable is the given distribution of shared birthdays (among all possible distributions for PP people chosen uniformly at random)?

입력

The first line gives a number nn where 1≤n≤3651 \le n \le 365. The second line contain integers c_1c\_1 through c_nc\_n, where 1≤c_i≤1001 \le c\_i \le 100 for all c_ic\_i. The value c_ic\_i represents the number of people who share a certain birthday (and whose birthday is distinct from the birthdays of everyone else in the group).

출력

Compute the probability bb of observing a group of people with the given distribution of shared birthdays. Since bb may be quite small, output instead log⁡_10(b)\log\_{10}(b). Your submission's answer is considered correct if it has an absolute or relative error of at most 10−610^{-6} from the judge's answer.

힌트

The first sample case shows P=2P=2 people with distinct birthdays. The probability of this occurring is b=364/365≈0.9972602740b = 364/365 \approx 0.9972602740, and log⁡_10(b)≈−0.001191480807419\log\_{10}(b) \approx -0.001191480807419.

The second sample case represents the third example in the list given earlier with P=10P=10 people. In this case, the probability is b≈0.0000489086b \approx 0.0000489086, and log⁡_10(b)≈−4.310614508857128\log\_{10}(b) \approx -4.310614508857128.

예제2

  1. 예제 1

    입력
    2
    1 1
    
    예상 출력
    -0.001191480807419
    
  2. 예제 2

    입력
    7
    1 1 2 1 3 1 1
    
    예상 출력
    -4.310614508857128