QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 1024 MB Total points: 100 Interactive

#5556. 邪恶的杜芬舒斯

Statistics

每年,世界上跑得最快的鸭嘴兽都会齐聚一堂,参加“伟大的鸭嘴兽爬行杯”(GCPC),在鸭嘴兽竞技场中爬行一圈。当然,鸭嘴兽泰瑞(Perry)也想参加这场盛大的赛事。泰瑞的宿敌杜芬舒斯博士(Dr. Doofenshmirtz)听说了这件事,并计划在泰瑞冲过 GCPC 终点线时将其抓获。为了成功实施他的邪恶计划,他需要找出泰瑞跑完一圈所需的时间。他知道泰瑞对 GCPC 的准备工作非常认真,并以 $1\,\text{m/s}$ 的恒定速度在竞技场中一圈又一圈地爬行进行训练。泰瑞的训练从本周六开始,杜芬舒斯博士知道他至少会跑 $10^{18}$ 秒。为了确定一圈的精确长度,杜芬舒斯博士发明了“测量仪”(Measurinator),可以测量泰瑞在当前这一圈中已经爬行的精确距离。不幸的是,测量仪在进行过多测量后会损坏,因此杜芬舒斯博士必须仔细规划使用它的时机,以确定一圈的长度。

环形跑道。图片来源:Kjrstie, Pixabay

交互

你的提交程序可以打印 “? t”,其中 $t$ ($0 \le t < 10^{18}$) 是你想要使用测量仪的时间点。时间 $t = 0$ 标志着泰瑞开始练习的时间点,即他在起终点线开始第一圈的时间。测量仪会返回一个整数 $x$,表示泰瑞在当前圈中的位置。注意,测量仪返回的不是泰瑞总共爬行的米数!因此,每当泰瑞到达起终点线时,测量仪都会返回 0。此外,请注意你最近弄丢了你的“时间旅行仪”,因此 $t$ 的值必须严格递增。

如果你确定了一圈的长度 $x$,请打印 “! x”。在此之后,你的程序应立即终止。

所有交互必须以换行符结束。此外,请注意你需要额外刷新标准输出,以确保查询被发送。例如,你可以使用: C++: std::cout << std::flush C: fflush(stdout) Java: System.out.flush() Python: sys.stdout.flush()

如果你的提交遵循了这些规则,找到了正确的一圈长度,并且使用的查询次数不超过 42 次,则被视为正确。注意,给出答案也算作一次查询。

保证一圈的长度为整数,至少为 1 米,最多为 $10^{12}$ 米。

提供了一个测试工具来帮助你开发解决方案。它可以从 DOMjudge 问题概览页面下载。

样例

样例 1

? 1
1
? 2
2
? 3
3
? 4
4
? 100
16
! 42

样例 2

? 10
10
? 20
20
? 30
30
? 40
40
? 10000
641
! 1337

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.