Birthday Paradox
시간 제한2초메모리 제한1024 MB
각 생일을 공유하는 사람 수가 주어질 때, P명 중 그 분포가 나타날 확률을 계산해 상용로그 값을 출력한다.
문제
The Birthday Paradox is the name given to the surprising fact that if there are just people in a group, there is a greater than 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 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 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 have different birthdays, or
- all have the same birthday, or
- people have the same birthday, other people have the same birthday (on a different day), and the remaining 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 people in a group, how probable is the given distribution of shared birthdays (among all possible distributions for people chosen uniformly at random)?
입력
The first line gives a number where . The second line contain integers through , where for all . The value 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 of observing a group of people with the given distribution of shared birthdays. Since may be quite small, output instead . Your submission's answer is considered correct if it has an absolute or relative error of at most from the judge's answer.
힌트
The first sample case shows people with distinct birthdays. The probability of this occurring is , and .
The second sample case represents the third example in the list given earlier with people. In this case, the probability is , and .