QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 512 MB Total points: 100 Interactive

#883. 感染估计

Statistics

X 国出现了一种新病毒,该国人口为 1000 万。这一次该国做好了准备,希望尽快开始追踪病毒的传播。目前已知至少有 100 人、至多有 5 000 000 人感染了病毒,你的任务是提供一个关于感染人数更准确的估计。

虽然检测大规模投产还需要一些时间,但其中一个研究实验室每天最多能进行 50 次检测。为了提高检测效率,研究人员决定将多个人的样本混合在一起进行检测。每次检测采集任意数量人的组织样本,如果其中至少有一人携带病毒,则检测结果为阳性,否则为阴性。检测按顺序进行——下一次检测前可以获得上一次检测的结果。

编写一个程序,决定如何进行检测,并提供一个感染人数的估计值,使其在实际感染人数的 2 倍误差范围内。

交互

你的程序最多可以进行 50 次检测,之后必须给出一个感染人数的估计值。要进行一次检测,输出 test k,其中 $1 \le k \le 10^7$ 为一个整数。评测机将返回一行,如果对 $k$ 个随机选择的人进行的检测结果为阳性,则返回 1;如果为阴性,则返回 0。这 $k$ 个人是不放回抽取的,即同一个人在单次检测中不能被选择两次。然而,不同次检测之间是独立的,因此同一个人可能在多轮检测中被选中。

要提供估计值,输出 estimate x,其中 $0 \le x \le 10^7$ 是你对感染人数的估计。如果你的估计值在正确答案 $y$ 的 2 倍误差范围内,即 $y/2 \le x \le 2y$,则该回答被视为正确。

你的程序总共会运行 100 次。你可以假设每次运行都是确定性的:在第 $i$ 次运行中进行相同的测试序列,总是会得到相同的测试结果序列。

请记住,每次输出后都要刷新标准输出缓冲区!

(注:下方的样例交互仅用于说明交互协议:仅凭所进行的四次测试,无法可靠地得出 250 000 这一感染人数的估计值。)

样例

输入 1

1
0
0
1

输出 1

test 20
test 20
test 23
test 22
estimate 250000

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.