CF1838A.Blackboard List

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Two integers were written on a blackboard. After that, the following step was carried out n−2n-2 times:

  • Select any two integers on the board, and write the absolute value of their difference on the board.

After this process was complete, the list of nn integers was shuffled. You are given the final list. Recover one of the initial two numbers. You do not need to recover the other one.

You are guaranteed that the input can be generated using the above process.

黑板上最初写了两个整数。随后,执行以下操作 n−2n-2 次:

  • 任选黑板上的两个整数,并将它们之差的绝对值写在黑板上。

该过程结束后,黑板上的 nn 个整数被随机打乱顺序。你将得到这个最终的列表。请恢复出最初的两个数中的任意一个(无需恢复另一个)。

保证输入数据可通过上述过程生成。

输入格式

The first line of the input contains a single integer tt (1≤t≤1001 \le t \le 100) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer nn (3≤n≤1003 \le n \le 100) — the size of the final list.

The next line of each test case contains nn integers a1,a2,…ana_1, a_2, \ldots a_n (−109≤ai≤109-10^9 \le a_i \le 10^9) — the shuffled list of numbers written on the blackboard.

It is guaranteed that the input was generated using the process described above.

输入的第一行包含一个整数 tt(1≤t≤1001 \le t \le 100),表示测试用例的数量。随后是各测试用例的描述。

每个测试用例的第一行包含一个整数 nn(3≤n≤1003 \le n \le 100),表示最终列表的大小。

每个测试用例的下一行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(−109≤ai≤109-10^9 \le a_i \le 10^9),即黑板上所写数字的打乱后列表。

保证输入是按照上述过程生成的。

输出格式

For each test case, output a single integer xx — one of the two initial numbers on the blackboard.

If there are multiple solutions, print any of them.

对于每个测试用例,输出一个整数 xx —— 黑板上两个初始数字中的一个。

如果存在多个解,输出任意一个即可。

输入输出样例

  • 输入#1

    9
    3
    9 2 7
    3
    15 -4 11
    4
    -9 1 11 -10
    5
    3 0 0 0 3
    7
    8 16 8 0 8 16 8
    4
    0 0 0 0
    10
    27 1 24 28 2 -1 26 25 28 27
    6
    600000000 800000000 0 -200000000 1000000000 800000000
    3
    0 -1000000000 1000000000

    输出#1

    9
    11
    -9
    3
    8
    0
    -1
    600000000
    0

说明/提示

For the first test case, aa can be produced by starting with either 99 and 22, and then writing down ∣9−2∣=7|9-2|=7, or starting with 99 and 77 and writing down ∣9−7∣=2|9-7|=2. So 22, 77, and 99 are all valid answers, because they all appear in at least one valid pair.

For the second test case, we can show that the two initial numbers must have been −4-4 and 1111.

For the fourth test case, the starting numbers could have been either 33 and 33, or 33 and 00, so 33 and 00 are both valid answers.

For the fifth test case, we can show that the starting numbers were 88 and 1616.

对于第一个测试用例,aa 可以通过以下两种方式得到:

  • 从 99 和 22 开始,然后写下 ∣9−2∣=7|9-2|=7;
  • 或从 99 和 77 开始,然后写下 ∣9−7∣=2|9-7|=2。
    因此,22、77 和 99 均为合法答案,因为它们均至少出现在一个合法的初始数对中。

对于第二个测试用例,我们可以证明两个初始数必定为 −4-4 和 1111。

对于第四个测试用例,初始数可能为 33 和 33,也可能为 33 和 00,因此 33 和 00 均为合法答案。

对于第五个测试用例,我们可以证明初始数为 88 和 1616。

输入解题思路,AI测评打分。不知道怎么写?

首页