QOJ.ac

QOJ

حد الوقت: 2.0 s حد الذاكرة: 256 MB مجموع النقاط: 100 تفاعلية قابلة للهجوم ✓

#16750. 交互题

الإحصائيات

评测机选择了两个数 $X_0$ 和 $P$($1 \le X_0 < P \le N$,$P$ 是一个质数)。给你数字 $N$:$P$ 的上限。

你的任务是猜出数字 $P$。

为此,你的程序将以 $A_i$($2 \le A_i \le N$,$A_i$ 是一个质数)的形式提出问题,其中 $i = 1, 2, \dots$ 是问题的编号。

在每次提问后,都会给出回答。如果第 $i$ 次提问没有猜中数字 $P$,评测机将计算 $X_i = (X_{i-1} \cdot A_i) \bmod P$,并返回 $X_i$ 与 $X_{i-1}$ 的比较结果(“>”、“<” 或 “=”)。

你的程序必须在不超过 42 次提问内猜出数字 $P$。

输入格式

输入的第一行包含一个整数 $N$($2 \le N \le 3 \cdot 10^5$)。你程序的提问所对应的回答将在单独的行中给出。

如果第 $i$ 次提问的数字就是 $P$,则会给出字符串 “OK” 作为回答。在其他情况下,将返回 $X_i$ 与 $X_{i-1}$ 的比较结果。如果 $X_i > X_{i-1}$,则回答为 “>”;如果 $X_i < X_{i-1}$,则回答为 “<”;否则回答为 “=”。

在收到回答 “OK” 后,你的程序必须停止发送问题。

输出格式

你的程序必须在单独的一行中输出单个问题。每个问题必须包含一个质数 $A_i$($2 \le A_i \le N$)。

样例

输入样例 1

100
<
>
>
>
>
>
OK

输出样例 1

29
43
23
17
29
17
73

说明

在所有满足 $P \le 100$ 的可能数对 $(X_0, P)$ 中,只有数对 $(41, 73)$ 满足第一个样例测试中给出的问题的以下等式:$X_1 < X_0, X_2 > X_1, X_3 > X_2, X_4 > X_3, X_5 > X_4, X_6 > X_5$($X_0 = 41, X_1 = 21, X_2 = 27, X_3 = 37, X_4 = 45, X_5 = 64, X_6 = 66$)。

从你的程序到交互程序的管道以及返回的管道大小是有限的。你的程序必须从标准输入中读取以避免死锁。死锁情况将被报告为 “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.