QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 2048 MB 満点: 100

#2940. 混合PCR检测

統計

聚合酶链式反应(PCR)检测是一种用于检测 COVID 的方法,它通过反复复制 DNA 样本来检测是否存在 COVID 特有的 DNA 片段。这一过程可能比较耗时,且所需的试剂可能有限。提高检测通量的一种建议是进行样本混合(pooling)。

其思路是将 $N$ 个样本混合在一起,并对混合后的样本进行 PCR 检测。如果检测结果为阴性,则无需进一步检测。如果检测结果为阳性,则必须对这 $N$ 个人分别进行重新检测。如果阳性检测的概率较低,这将显著减少所需的检测次数。

请编写一个程序,输入单个人检测呈阳性的概率 $p$,并输出最优的样本混合数量 $N$。

若 $P$ 为这 $N$ 个人检测结果均为阴性的概率,则所需的期望检测次数 $E(T)$ 为:

$$E(T) = 1 \cdot P + N \cdot (1 - P)$$

请选择 $N$ 以最小化 $E(T) / N$。

例如,如果 $N$ 为 $2$ 且 $p$ 为 $0.5$,则 $P$ 为 $0.25$,且 $E(T) = 0.25 + 2 \cdot 0.75 = 1.75$,这仅比 $N$ 略小。

为了确保每个人的样本量充足,要求 $N$ 不超过 $16$。

输入格式

输入包含一行,为一个十进制浮点数 $p$ ($0 < p < 1$),表示单个人检测出 COVID 阳性的概率。

输出格式

输出包含一行,为一个十进制整数。如果对于所有 $N$,都有 $E(T) \ge N$,则输出 $1$。否则,输出使 $E(T) / N$ 最小化的 $N$ 值,其中 $2 \le N \le 16$。

样例

样例输入 1

0.1

样例输出 1

4

样例输入 2

0.02

样例输出 2

8

样例输入 3

0.01

样例输出 3

10

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.