102801: [AtCoder]ABC280 B - Inverse Prefix Sum

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:1 Solved:0

Description

Score : $200$ points

Problem Statement

You are given an integer $N$ and a sequence $S=(S_1,\ldots,S_N)$ of length $N$.

Find a sequence $A=(A_1,\ldots,A_N)$ of length $N$ that satisfies the following condition for all $k=1,\ldots,N$:

  • $A_1+A_2+\ldots+A_k = S_k$.

Such a sequence $A$ always exists and is unique.

Constraints

  • $1 \leq N \leq 10$
  • $-10^9\leq S_i \leq 10^9$
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:

$N$
$S_1$ $\ldots$ $S_N$

Output

Print the elements of a sequence $A=(A_1,\ldots,A_N)$ that satisfies all the conditions in order, separated by spaces.


Sample Input 1

3
3 4 8

Sample Output 1

3 1 4

The sequence in the output actually satisfies all the conditions:

  • $A_1=3=S_1$;
  • $A_1+A_2=3+1=4=S_2$;
  • $A_1+A_2+A_3=3+1+4=8=S_3$.

Sample Input 2

10
314159265 358979323 846264338 -327950288 419716939 -937510582 97494459 230781640 628620899 -862803482

Sample Output 2

314159265 44820058 487285015 -1174214626 747667227 -1357227521 1035005041 133287181 397839259 -1491424381

Input

题意翻译

给定长度为 $n$ 的序列 ${S}$ ,请你构造一个长度为 $n$ 的序列 ${A}$ 使得对于任意 $k \in [1,n]$ 有 $\sum_{i=1}^{i=k} A_i =S_i$ 成立。

Output

分数:200分

问题描述

给你一个整数 $N$ 和一个长度为 $N$ 的序列 $S=(S_1,\ldots,S_N)$。

找出一个长度为 $N$ 的序列 $A=(A_1,\ldots,A_N)$,使得对于所有 $k=1,\ldots,N$,都满足以下条件:

  • $A_1+A_2+\ldots+A_k = S_k$。

这样的序列 $A$ 总是存在的,且是唯一的。

约束条件

  • $1 \leq N \leq 10$
  • $-10^9\leq S_i \leq 10^9$
  • 输入中的所有值都是整数。

输入

输入从标准输入以以下格式给出:

$N$
$S_1$ $\ldots$ $S_N$

输出

按顺序打印出满足所有条件的序列 $A=(A_1,\ldots,A_N)$ 的元素,用空格分隔。


样例输入 1

3
3 4 8

样例输出 1

3 1 4

输出中的序列实际上满足了所有条件:

  • $A_1=3=S_1$;
  • $A_1+A_2=3+1=4=S_2$;
  • $A_1+A_2+A_3=3+1+4=8=S_3$。

样例输入 2

10
314159265 358979323 846264338 -327950288 419716939 -937510582 97494459 230781640 628620899 -862803482

样例输出 2

314159265 44820058 487285015 -1174214626 747667227 -1357227521 1035005041 133287181 397839259 -1491424381

加入题单

算法标签: