QOJ.ac

QOJ

时间限制: 4 s 内存限制: 2048 MB 总分: 100

#5127. 让竞赛电脑死机

统计

你正在为一场黑客马拉松编写代码,需要解码二进制 ALGOL 打孔卡。你已经想出了最优解,现在只需要将其输入。该解决方案包含 $c$ 个字符,你的打字速度为每单位时间 1 个字符。然而,你的电脑容易突然崩溃:在你输入的每一个字符之后,电脑都有 $p$ 的概率崩溃,此时你需要从头开始。崩溃后的恢复需要 $r$ 个单位时间,之后你可以从上次保存代码的位置继续输入。

你可以随时点击“保存”(耗时 $t$ 个单位时间)来保存你的代码,以便在崩溃后从该点重新开始。点击“保存”不会导致电脑崩溃。

请确定你需要多少(期望)时间单位来完成代码。注意,在输入最后一个字符后,代码也应该被保存。

二十世纪中叶的打孔卡。CC BY 2.0,作者 Pete Birkinshaw,来自维基百科

输入格式

输入包含:

  • 一行,包含三个整数 $c$、$t$ 和 $r$ ($1 \le c \le 2000, 0 \le t, r \le 10^9$),分别表示字符数量、点击“保存”的时间成本以及崩溃后的恢复时间成本。
  • 一行,包含一个浮点数 $p$ ($0.001 \le p \le 0.999$,小数点后最多 10 位),表示每输入一个字符后电脑崩溃的概率。

输出格式

输出完成代码所需的期望时间单位数。

你的答案的绝对误差或相对误差应不超过 $10^{-6}$。

样例

样例输入 1

2 1 5
0.25

样例输出 1

8.0

样例输入 2

3 5 2
0.5

样例输出 2

26.0

样例输入 3

10 4 5
0.327

样例输出 3

68.664967357

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.