QOJ.ac

QOJ

実行時間制限: 10 s メモリ制限: 1024 MB 満点: 29

#5773. 百万富翁

統計

你受邀参加了一档热门电视节目“你想成为百万富翁吗?”。当然,你肯定想!

比赛规则很简单:

  • 在游戏开始前,主持人会转动幸运轮盘来确定 P,即赢得每一轮赌注的概率。
  • 你初始拥有 X 美元。
  • 共有 M 轮下注。在每一轮中,你可以押注当前资金的任意部分,包括不押注或全押。押注金额不限于整数美元或美分。 如果你赢了,你的总金额将增加你押注的金额。否则,你的总金额将减少你押注的金额。
  • 所有轮次结束后,只有当你累计达到 $1000000 或更多时,你才能保留你的奖金(此时金额向下取整为整数美元)。否则你将一无所有。

给定 MPX,请确定如果你采取最优策略(即以最大化成为百万富翁概率的方式进行游戏),你赢得至少 $1000000 的概率。

输入格式

输入的第一行包含测试用例的数量 N

接下来的 N 行,每行格式为 "M P X",其中:

  • M 是一个整数,表示下注的轮数。
  • P 是一个实数,表示每一轮获胜的概率。
  • X 是一个整数,表示初始资金(美元)。

输出格式

对于每个测试用例,输出一行 "Case #X: Y",其中:

  • X 是测试用例编号,从 1 开始。
  • Y 是成为百万富翁的概率,介于 0 和 1 之间。

相对误差或绝对误差不超过 $10^{-6}$ 的答案将被视为正确。

数据范围

$1 \le N \le 100$

$0 \le P \le 1.0$,小数点后最多有 6 位数字。

$1 \le X \le 1000000$

小数据集(测试集 1 - 可见;13 分)

$1 \le M \le 5$

大数据集(测试集 2 - 隐藏;16 分)

$1 \le M \le 15$

样例

样例输入 1

2
1 0.5 500000
3 0.75 600000

样例输出 1

Case #1: 0.500000
Case #2: 0.843750

说明

在第一个案例中,达到 $1000000 的唯一方法是在这一轮中全押。

在第二个案例中,你可以采取策略,使得即使输掉一轮赌注,仍然有机会达到 $1000000。以下是一种可行的方法:

  • 第一轮你有 $600000。押注 $150000。
  • 如果第一轮输了,你剩下 $450000。押注 $100000。
  • 如果第一轮输了且第二轮赢了,你剩下 $550000。押注 $450000。
  • 如果第一轮赢了,你剩下 $750000。押注 $250000。
  • 如果第一轮赢了且第二轮输了,你剩下 $500000。押注 $500000。

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.