QOJ.ac

QOJ

时间限制: 15.0 s 内存限制: 512 MB 总分: 100

#11598. 致敬

统计

天子,我们敬爱的皇帝,命令你,他的宰相,向 $n$ 个邻国勒索贡品。每个附属国都被分配了需要支付的银币数量——对于第 $i$ 个王国,该数量为 $a_i$。为了彰显皇恩浩荡,皇帝决定只从部分国家收取贡品,而免除其余国家的贡品。你那过度热心的财务大臣在写下所有 $a_i$ 后,已经计算出了所有可能的 $2^n - 1$ 个收入值——即所有非空子集贡品之和。不幸的是,大臣在过程中弄丢了记录原始贡品数值的纸张。由于这一失职,加上他那糟糕的书法,他被立即处决了。

现在你只剩下这 $2^n - 1$ 个写得乱七八糟的和。你能从中恢复出原始的贡品数值吗?

输入格式

第一行包含测试用例的数量 $z$ ($1 \le z \le 200$)。接下来是各测试用例的描述。

每个测试用例包含两行:第一行包含一个数字 $n$ ($1 \le n \le 20$),第二行包含 $2^n - 1$ 个不超过 $2 \cdot 10^9$ 的整数,表示所有可能的贡品之和。假设贡品数值均为正整数。所有测试用例中的和的总数不超过 $10^7$。

输出格式

对于每个测试用例,按升序输出恢复出的 $a_i$ 值($i = 1, 2, \dots, n$)。如果不存在符合输入的值,或者存在多种可能性,则直接输出 “NO” ——你不能处决同一个人两次。

样例

输入 1

1
3
1 2 3 3 4 5 6

输出 1

1 2 3

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.