NvidiaOA #1
Reconstruct Array from Prefix-Skip Sum
估计简单可在线判题
考点(AI 标注)位运算
pref[i] equals the sum of all elements of the original array except the i-th one. Recover the original array. This site guarantees that an integer solution exists and that N is at least 2; N=1 cannot be determined uniquely, so it is not part of this protocol.
This site uses a standard input/output protocol.
输入格式
The first line contains N, and the second line contains N values pref. This site uses 2≤N≤100000 and −10⁹≤pref[i]≤10⁹, and an integer solution is guaranteed to exist.
输出格式
Output N integers in original index order.
样例 1
输入:
3
2 6 4
输出:
4 0 2
样例 2
输入:
3
11 9 8
输出:
3 5 6
样例 3
输入:
2
-3 5
输出:
5 -3
样例说明
Example 1: the total is 6, and the answer is 4, 0, 2. Example 2: the total is 14, and the answer is 3, 5, 6. Example 3: with two elements, each pref is the other element, so the answer is 5, −3.