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?

一行中写有 nn 个整数 b1, b2, …, bnb_1,\,b_2,\,\dots,\,b_n。对于每个从 11 到 nn 的 ii,值 aia_i 由乌鸦执行如下过程定义:

  • 乌鸦首先将 aia_i 设为 00;
  • 然后,乌鸦将 bib_i 加到 aia_i 上,再减去 bi+1b_{i+1},再加上 bi+2b_{i+2},依此类推,直到第 nn 个数。因此,

    ai=bi−bi+1+bi+2−bi+3+⋯a_i = b_i - b_{i+1} + b_{i+2} - b_{i+3} + \cdots

Memory 给出了值 a1, a2, …, ana_1,\,a_2,\,\dots,\,a_n,现在他希望你找出最初写在一行中的数 b1, b2, …, bnb_1,\,b_2,\,\dots,\,b_n。你能做到吗?

输入格式

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.

输入的第一行包含一个整数 nn(2≤n≤100 0002 \leq n \leq 100\,000)—— 表示写在一行中的整数个数。

下一行包含 nn 个整数,其中第 ii 个为 aia_i(−109≤ai≤109-10^9 \leq a_i \leq 10^9)—— 表示第 ii 个数的值。

输出格式

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, …, bnb_1,\,b_2,\,\dots,\,b_n 的 nn 个整数。保证答案唯一,且在 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 分别开始时,乌鸦报告的数字依次为 66、−4-4、88、−2-2 和 33。容易验证序列 2 4 6 1 32\ 4\ 6\ 1\ 3 满足所有报告。例如,6=2−4+6−1+36 = 2 - 4 + 6 - 1 + 3,且 −4=4−6+1−3-4 = 4 - 6 + 1 - 3。

在第二个样例测试中,序列 1, −3, 4, 11, 61,\ -3,\ 4,\ 11,\ 6 满足所有报告。例如,5=11−65 = 11 - 6,且 6=66 = 6。

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

首页