QOJ.ac

QOJ

Limite de temps : 1.0 s Limite de mémoire : 256 MB Points totaux : 100 Interactif

#15608. 67

Statistiques

这是一个交互式问题。

Busy Beaver 有一个隐藏的数组 $a_1, \dots, a_N$,其中对于所有 $i$ 均有 $1 \le a_i \le 10^9$,且数组中任意两个元素都互质。(如果两个正整数的公因数只有 $1$,则称它们互质。)

你最多可以进行 $100$ 次如下形式的询问:

  • 选择两个不同的下标 $i$ 和 $j$。作为响应,你将获得乘积 $a_i \times a_j$。

设 $Q$ 为你确定 Busy Beaver 的数组所使用的最大询问次数。要获得满分,你必须满足 $Q \le 67$。

输入格式

每个测试点包含多个测试用例。第一行包含一个整数 $T$ ($1 \le T \le 1000$) — 测试用例的数量。

每个测试用例的第一行包含一个整数 $N$ ($5 \le N \le 100$)。在读取此行后,你应该开始交互。

交互

对于每个测试用例,首先读取 $N$。

要进行询问,请输出 ? i j ($1 \le i, j \le N$ 且 $i \neq j$),不带引号。然后,你应该读入一个整数 — 乘积 $a_i \times a_j$。在单个测试用例中,你最多可以进行 $100$ 次此类询问。

如果你收到的整数是 $-1$ 而不是答案,这意味着你的程序进行了无效的询问、超过了 $100$ 次询问的限制,或者在之前的某个测试用例中给出了错误的答案。你的程序必须立即终止以获得“答案错误(Wrong Answer)”的评测结果。否则,由于你的程序将继续从已关闭的流中读取,你可能会获得任意的评测结果。

当你准备好给出最终答案时,输出 ! a1 ... aN ($1 \le a_i \le 10^9$),不带引号 — 即 Busy Beaver 的数组。给出此答案不计入 $100$ 次询问的限制。之后,你的程序必须继续解决剩余的测试用例,或者如果所有测试用例都已解决,则退出程序。

在打印询问后,请不要忘记输出换行符并刷新输出缓冲区。为此,请使用:

  • C++ 中的 fflush(stdout)cout.flush()
  • Java 中的 System.out.flush()
  • Python 中的 stdout.flush()
  • 其他语言请参阅对应语言的文档。

子任务

  • 要获得满分,你必须满足 $Q \le 67$。
  • 要获得部分分,若使用 $67 < Q \le 100$ 次询问,将获得 $\lfloor 1.067^{125-Q} \rfloor$ 分。

样例

输入样例 1

2
5
77
30
85
5
69

输出样例 1

? 1 2
? 3 4
? 4 5
! 7 11 6 5 17
? 1 5
! 1 40 61 41 69

说明

在实际运行中,程序是无法预先知道隐藏数组的;此处显示隐藏数组仅为了解释样例。

在第一个测试用例中,评测机输出 $5$,因此 $N = 5$。其隐藏数组为 $[7, 11, 6, 5, 17]$。

  • 程序询问 ? 1 2 并收到 $77$,即 $7 \times 11$。
  • 程序询问 ? 3 4 并收到 $30$,即 $6 \times 5$。
  • 程序询问 ? 4 5 并收到 $85$,即 $5 \times 17$。

随后程序正确输出 ! 7 11 6 5 17

在第二个测试用例中,评测机输出 $5$。其隐藏数组为 $[1, 40, 61, 41, 69]$。

程序询问 ? 1 5 并收到 $69$,即 $1 \times 69$。随后输出 ! 1 40 61 41 69,与评测机的数组一致。

这展示了一个有效的交互过程;任何在允许的询问次数内正确确定数组的方案都是可以接受的。

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.