CF2274A.The Projections of Paco
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given n integers a1,a2,…,an representing points on a number line. Paco has a token that starts at coordinate 0.
Reflecting the token about a point moves it to the other side of that point, keeping the same distance from it. If the token is already at that point, it stays there.
Paco's token (blue) being reflected about a point (red).
Choose an integer p. Paco's token is reflected about the points with coordinates p,a1,a2,…,an, in this order, exactly once each.
Help Paco find p such that his token ends at exactly coordinate 0. This is very important for him. It can be shown that exactly one such integer exists.
给你 n 个整数 a1,a2,…,an,它们表示数轴上的若干点。Paco 有一个初始位于坐标 0 处的标记。
关于某一点对标记进行反射,是指将其移动到该点另一侧、且与该点保持相同距离的位置。若标记已位于该点,则其位置保持不变。
Paco 的标记(蓝色)关于某一点(红色)被反射。
请选择一个整数 p。Paco 的标记将依次、且仅一次地关于坐标为 p,a1,a2,…,an 的点进行反射。
请帮助 Paco 找到满足条件的 p,使得标记最终恰好落在坐标 0 处。这对 Paco 至关重要。可以证明,满足条件的整数 p 恰好存在唯一一个。
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤104). The description of the test cases follows.
The first line of each test case contains a single integer n (1≤n≤105).
The second line contains n integers a1,a2,…,an (−104≤ai≤104).
It is guaranteed that the sum of n over all test cases does not exceed 105.
每个测试包含多个测试用例。第一行包含测试用例的数量 t(1≤t≤104)。随后是各测试用例的描述。
每个测试用例的第一行包含一个整数 n(1≤n≤105)。
第二行包含 n 个整数 a1,a2,…,an(−104≤ai≤104)。
保证所有测试用例的 n 之和不超过 105。
输出格式
For each test case, print the integer p.
对于每个测试用例,输出整数 p。
输入输出样例
输入#1
5 1 3 2 2 5 3 2 7 1 4 -3 0 -3 0 1 0
输出#1
3 -3 -4 -6 0
说明/提示
In the first test case, choose p=3. Paco's token moves from 0 to 6 and then back to 0.
In the second test case, choose p=−3. Paco's token visits coordinates 0→−6→10→0.
In the third test case, choose p=−4. Paco's token visits coordinates 0→−8→12→2→0.
在第一个测试用例中,选择 p=3。Paco 的棋子从 0 移动到 6,然后返回 0。
在第二个测试用例中,选择 p=−3。Paco 的棋子经过的坐标为 0→−6→10→0。
在第三个测试用例中,选择 p=−4。Paco 的棋子经过的坐标为 0→−8→12→2→0。
输入解题思路,AI测评打分。不知道怎么写?