QOJ.ac

QOJ

Límite de tiempo: 2 s Límite de memoria: 2048 MB Puntuación total: 100

#5105. 自由标记之手

Estadísticas

有一个广为人知的心理魔术,被称为 Fitch Cheney 魔术。从一副 $n$ 张扑克牌中,随机均匀地抽取 $k$ 张牌交给助手,此时魔术师不在房间内。助手将选出的 $k$ 张牌中的 $k-1$ 张正面朝上放在桌子上,剩下的一张牌背面朝上放在最后(参见示例图片)。魔术师进入房间,观察桌上的牌,并宣布那张背面朝上的第 $k$ 张牌是什么,尽管它的牌面是隐藏的。这个魔术通常在 $n = 52$ 且 $k = 5$ 的情况下进行。

k = 5 时的牌面摆放示例

助手有两种向魔术师传递信息的方式。首先,他们可以选择 $k$ 张牌中的哪一张保持隐藏。其次,他们可以以特定的方式重新排列其余的 $k-1$ 张牌。对于 $n = 52$ 和 $k = 5$ 的情况,这两种技术都需要用到,因为重新排列四张牌只有 24 种方式,不足以可靠地传达第五张牌的信息。想出一个简单易记的策略来执行这个魔术是一个有趣的练习,但现在你有另一个顾虑。

你原本计划今天表演这个魔术,但刚刚得知这副牌比你预期的要多。这个魔术可能无法实现!在绝望中,你决定稍微作弊。你有 $m$ 种可区分的方式来标记扑克牌的背面。你已经标记了所有 $n$ 张牌的背面,这使你能够缩小第 $k$ 张牌的可能性范围。例如,如果有 6 张牌是用某种特定方法标记的,而你看到第 $k$ 张牌的背面是用该方法标记的,你就知道它一定是那 6 张牌中的一张。

假设你和助手执行最优(但可能非常复杂!)策略,确定你成功猜出第 $k$ 张牌的概率。

输入格式

输入包含一行,包含多个整数。第一个整数为 $k$ ($2 \le k \le 10$),表示将要选出的牌数。第二个整数为 $m$ ($1 \le m \le 10$),表示标记牌的方法数。该行剩余部分为 $m$ 个正整数,分别表示每种不同标记方法对应的牌数。这 $m$ 个整数之和为 $n$ ($k \le n \le 10^9$),即牌的总数。

输出格式

输出猜对第 $k$ 张牌的最高可能概率,精确到绝对误差 $10^{-9}$ 以内。

样例

样例输入 1

4 1 28

样例输出 1

0.96

样例输入 2

3 3 5 12 3

样例输出 2

0.854385964912

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.