QOJ.ac

QOJ

実行時間制限: 2 s メモリ制限: 1024 MB 満点: 100

#3600. 生日悖论

統計

生日悖论(Birthday Paradox)是一个令人惊讶的事实:如果一个群体中有 23 个人,那么其中至少有两个人生日相同的概率超过 50%。其背后的假设是:所有生日出现的概率相等(这并不完全正确),一年恰好有 365 天(这也不完全正确),且群体中的人是均匀随机选择的(这是一个有些奇怪的前提)。对于本题,我们将接受这些假设。

考虑如果我们随机选择 $P = 10$ 个人的群体,我们可能会观察到什么。一旦选定了一个群体,我们根据共享的生日将他们分成若干子组。在许多其他可能性中,我们可能会观察到以下关于共享生日的分布:

  • 所有 10 个人的生日都不同,或者
  • 所有 10 个人的生日都相同,或者
  • 3 个人有相同的生日,另外 2 个人有相同的生日(在不同的一天),其余 5 个人生日各不相同。

当然,这些分布发生的概率各不相同。

你的任务是计算给定生日共享分布的概率。也就是说,如果一个群体中有 $P$ 个人,那么给定生日共享分布的概率是多少(在所有 $P$ 个人均匀随机选择的可能分布中)?

n 个人中出现 n 个唯一生日的概率。

输入格式

第一行给出一个数字 $n$,其中 $1 \le n \le 365$。第二行包含整数 $c_1$ 到 $c_n$,其中对于所有 $c_i$ 满足 $1 \le c_i \le 100$。值 $c_i$ 表示共享某个特定生日的人数(且该生日与群体中其他人的生日不同)。

输出格式

计算观察到具有给定共享生日分布的群体的概率 $b$。由于 $b$ 可能非常小,请输出 $\log_{10}(b)$。如果你的答案与裁判答案的绝对误差或相对误差不超过 $10^{-6}$,则视为正确。

说明

第一个样例展示了 $P = 2$ 个人且生日各不相同的情况。这种情况发生的概率为 $b = 364/365 \approx 0.9972602740$,且 $\log_{10}(b) \approx -0.001191480807419$。

第二个样例代表了前面列表中提到的第三个例子,其中 $P = 10$ 个人。在这种情况下,概率为 $b \approx 0.0000489086$,且 $\log_{10}(b) \approx -4.310614508857128$。

样例

输入 1

2
1 1

输出 1

-0.001191480807419

输入 2

7
1 1 2 1 3 1 1

输出 2

-4.310614508857128

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.