CF712A.Memory and Crow
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There are n integers _b_1, _b_2, ..., b__n written in a row. For all i from 1 to n, values a__i are defined by the crows performing the following procedure:
- The crow sets a__i initially 0.
- The crow then adds b__i to a__i, subtracts b__i + 1, adds the b__i + 2 number, and so on until the n'th number. Thus, a__i = b__i - b__i + 1 + b__i + 2 - b__i + 3....
Memory gives you the values _a_1, _a_2, ..., a__n, and he now wants you to find the initial numbers _b_1, _b_2, ..., b__n written in the row? Can you do it?
一行中写有 n 个整数 b1,b2,…,bn。对于每个从 1 到 n 的 i,值 ai 由乌鸦执行如下过程定义:
- 乌鸦首先将 ai 设为 0;
- 然后,乌鸦将 bi 加到 ai 上,再减去 bi+1,再加上 bi+2,依此类推,直到第 n 个数。因此,
ai=bi−bi+1+bi+2−bi+3+⋯
Memory 给出了值 a1,a2,…,an,现在他希望你找出最初写在一行中的数 b1,b2,…,bn。你能做到吗?
输入格式
The first line of the input contains a single integer n (2 ≤ n ≤ 100 000) — the number of integers written in the row.
The next line contains n, the i'th of which is a__i ( - 109 ≤ a__i ≤ 109) — the value of the i'th number.
输入的第一行包含一个整数 n(2≤n≤100000)—— 表示写在一行中的整数个数。
下一行包含 n 个整数,其中第 i 个为 ai(−109≤ai≤109)—— 表示第 i 个数的值。
输出格式
Print n integers corresponding to the sequence _b_1, _b_2, ..., b__n. It's guaranteed that the answer is unique and fits in 32-bit integer type.
输出对应于序列 b1,b2,…,bn 的 n 个整数。保证答案唯一,且在 32 位整数类型范围内。
输入输出样例
输入#1
5 6 -4 8 -2 3
输出#1
2 4 6 1 3
输入#2
5 3 -2 -1 5 6
输出#2
1 -3 4 11 6
说明/提示
In the first sample test, the crows report the numbers 6, - 4, 8, - 2, and 3 when he starts at indices 1, 2, 3, 4 and 5 respectively. It is easy to check that the sequence 2 4 6 1 3 satisfies the reports. For example, 6 = 2 - 4 + 6 - 1 + 3, and - 4 = 4 - 6 + 1 - 3.
In the second sample test, the sequence 1, - 3, 4, 11, 6 satisfies the reports. For example, 5 = 11 - 6 and 6 = 6.
在第一个样例测试中,当从索引 1、2、3、4 和 5 分别开始时,乌鸦报告的数字依次为 6、−4、8、−2 和 3。容易验证序列 2 4 6 1 3 满足所有报告。例如,6=2−4+6−1+3,且 −4=4−6+1−3。
在第二个样例测试中,序列 1, −3, 4, 11, 6 满足所有报告。例如,5=11−6,且 6=6。
输入解题思路,AI测评打分。不知道怎么写?