No.970 Sequence Conversion Machine
Problem Statement
When a sequence $a$ of $n$ elements is put into the input slot of a sequence conversion machine, a sequence $b$ of $n$ elements comes out of the output slot.
Here, the value of the $i$-th element $b_i$ of $b$ is equal to the arithmetic mean of the $n-1$ elements obtained by removing the $i$-th element $a_i$ from $a$.
For example, if the sequence $a=\{3,5,7\}$ is put in, the values of the output sequence $b$ are
\[b_1=\frac{5+7}{2}=6,\ b_2=\frac{3+7}{2}=5,\ b_3=\frac{3+5}{2}=4\]
.
One day, you noticed that there is an integer sequence $y_1,...,y_N$ of $N$ elements at the output slot of the sequence conversion machine.
Apparently, your past self put in some integer sequence $x_1,...,x_N$ and then forgot about it.
You became curious about what integer sequence was put in to produce $y$, and decided to find it.
Input
$N$ $y_1 \ y_2 \ ... \ y_N$
- $2 \le N \le 10^5$
- $-1000 \le y_i \le 1000 $
- All inputs are integers.
Output
Output the values of the desired integer sequence $x$ on a single line, separated by spaces.
It can be shown that a unique answer exists for any input satisfying the constraints.
Print a newline at the end.
Sample
Sample 1
Input
3 6 5 4
Output
3 5 7
This corresponds to the sequences $a,b$ given as the example at the beginning of the problem statement.
Sample 2
Input
2 -100 100
Output
100 -100
Sample 3
Input
6 0 0 0 0 0 0
Output
0 0 0 0 0 0
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
沙耶花
shibh308