QOJ.ac

QOJ

Time Limit: 6 s Memory Limit: 1024 MB Total points: 17

#5923. 作弊者

Statistics

你在当地赌场玩了一段时间的轮盘赌。轮盘赌是一种简单的赌场游戏,多名玩家在 $0$ 到 $36$(含 $0$ 和 $36$)之间的一个或多个数字上押注。接着,轮盘向一个方向旋转,小球向相反方向滚动。轮盘上包含 $0$ 到 $36$ 这些数字。有些真实的轮盘还有一个标有 $00$ 的位置,但我们的轮盘没有。最终,小球会落在其中一个数字上。如果玩家押注的数字正好是小球落下的数字,他将获得押注金额 $36$ 倍的奖金(即该笔押注的利润为押注金额的 $35$ 倍)。押注在其他数字上的金额则全部输掉。

不幸的是,你的运气一直不好,整晚都在输钱。某一刻,你开始怀疑这个轮盘游戏是否公平。在进一步观察后,你发现了一个对赌场有利的规律:小球总是落在当前总押注金额最少的数字上!如果有多个数字的总押注金额并列最少,小球会等概率地落在其中一个数字上。

当然,你会向有关部门举报这种作弊行为,但在此之前,你想利用这一新发现的知识赢回你的钱。为此,你等到其他所有玩家都下注后,再进行自己的押注。不幸的是,你的预算有限,因此你的总押注金额不能超过预算。你可以选择在零个或多个不同的数字上押注,每个数字的押注金额必须是正整数(不同数字的押注金额可以不同),只要所有押注的总和不超过你的预算即可。请问你能获得的最大期望利润是多少?

输入格式

输入的第一行包含测试用例的数量 $T$。接下来是 $T$ 个测试用例。 每个测试用例包含两行。第一行包含两个整数:你剩余的预算 $B$ 和其他玩家已经押注的数字个数 $N$。第二行包含 $N$ 个整数 $X_i$,表示其他玩家在这些数字上分别押注的总金额。

输出格式

对于每个测试用例,输出一行 "Case #x: ",后跟如果你采取最优策略押注所能获得的最大期望利润。如果利润值与正确答案的绝对误差或相对误差在 $10^{-6}$ 以内,则视为正确。有关浮点数格式的说明,请参阅 FAQ

样例

输入格式 1

3
100 1
10
34 3
5 6 7
34 4
1 1 10 10

输出格式 1

Case #1: 0
Case #2: 2
Case #3: 0.9428571429

说明

在样例 2 中,在 34 个未被押注的数字上各押注 1,保证获得 36 的回报,利润为 $36 - 34 = 2$。在样例 3 中,在 33 个未被押注的数字上各押注 1,这样你以 $33/35$ 的概率赢得 36。这带来的期望利润为 $33/35 \times 36 - 33$。

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.