QOJ.ac

QOJ

実行時間制限: 1.0 s メモリ制限: 512 MB 満点: 100 インタラクティブ ハック可能 ✓

#16726. 有趣的交互题点子

統計

这是一个交互式问题。

评测机选择了两个整数 $x_0$ 和 $m$($0 \le x_0 < m \le n$)。给你一个数字 $n$:$m$ 的上限。

你的任务是猜出这两个整数 $x_0$ 和 $m$。

为此,你的程序将以 “$a_i$”($1 \le a_i \le n$)的形式进行提问,其中 $i = 1, 2, \dots$ 是提问的序号。

每次提问后,评测机计算 $x_i = (x_{i-1} + a_i) \bmod m$,并告诉你 $x_i$ 与 $x_{i-1}$ 的大小比较结果(‘>’、‘<’ 或 ‘=’)。

最后一个问题必须是 “0 $x_0$ $m$” 的形式。

你的程序必须在不超过 2016 次提问内猜出数字 $x_0$ 和 $m$。

输入格式

输入的第一行包含一个整数 $n$($1 \le n \le 10^{18}$)。此后,对于每个以 “$a_i$” 形式提出的新问题,输入将包含一行,其中仅有一个字符:$x_i$ 与 $x_{i-1}$ 的比较结果。如果 $x_i > x_{i-1}$,则结果为 ‘>’;如果 $x_i < x_{i-1}$,则结果为 ‘<’;否则结果为 ‘=’。

输出格式

你的程序必须在单独的一行中输出每个问题。除最后一个问题外,每个问题必须由单个整数 $a_i$($1 \le a_i \le n$)组成。最后一个问题必须是 “0 $x_0$ $m$”($0 \le x_0 < m \le n$)的形式。

样例

输入样例 1

2
<
>
<

输出样例 1

1
1
1
0 1 2

说明

从你的程序到交互程序的管道以及返回的管道大小是有限的。你的程序必须从标准输入中读取以避免死锁。死锁状态会被报告为 “Time Limit Exceeded”。

要刷新标准输出流,请使用以下语句:

  • 在 C 中,使用 fflush(stdout);
  • 在 C++ 中,使用 cout.flush();
  • 在 Java 中,使用 System.out.flush();
  • 在 Python 中,使用 sys.stdout.flush()

如果你的程序在标准输入上接收到 EOF(文件结束)信号,它必须立即以退出码 0 退出。不遵守此要求可能会导致 “Time Limit Exceeded” 错误。

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.