A16048 | Blackboard List
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Two integers were written on a blackboard. After that, the following step was carried out $n-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 $n$ 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.
- 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 $n$ 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.
输入格式
The first line of the input contains a single integer $t$ ( $1 \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 $n$ ( $3 \le n \le 100$ ) — the size of the final list.
The next line of each test case contains $n$ integers $a_1, a_2, \ldots a_n$ ( $-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.
The first line of each test case contains a single integer $n$ ( $3 \le n \le 100$ ) — the size of the final list.
The next line of each test case contains $n$ integers $a_1, a_2, \ldots a_n$ ( $-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.
输出格式
For each test case, output a single integer $x$ — one of the two initial numbers on the blackboard.
If there are multiple solutions, print any of them.
If there are multiple solutions, print any of them.
输入输出样例
输入 #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, $a$ can be produced by starting with either $9$ and $2$ , and then writing down $|9-2|=7$ , or starting with $9$ and $7$ and writing down $|9-7|=2$ . So $2$ , $7$ , and $9$ 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$ and $11$ .
For the fourth test case, the starting numbers could have been either $3$ and $3$ , or $3$ and $0$ , so $3$ and $0$ are both valid answers.
For the fifth test case, we can show that the starting numbers were $8$ and $16$ .
For the second test case, we can show that the two initial numbers must have been $-4$ and $11$ .
For the fourth test case, the starting numbers could have been either $3$ and $3$ , or $3$ and $0$ , so $3$ and $0$ are both valid answers.
For the fifth test case, we can show that the starting numbers were $8$ and $16$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted