P29349 [洛谷] [COCI2007-2008#2] KEMIJA
入门
题目描述

Problem Description

You are tasked with constructing a ring of $n$ numbers such that when each number in the ring is added to its two adjacent numbers, the result matches a given target ring.

Input Format

The first line of input contains an integer $n$.

The next $n$ lines each contain an integer representing the given target ring.

Output Format

The output should consist of $n$ lines, each containing an integer describing the constructed ring.

Note: There may be multiple valid constructions; this problem uses a special judge (SPJ).

Sample Input and Output

Sample Input #1

3
5
5
5

Sample Output #1

2
1
2

Sample Input #2

4
20
15
17
14

Sample Output #2

5
8
2
7

Sample Input #3

5
7
8
9
10
11

Sample Output #3

4
1
3
5
2

Notes

Data Size and Constraints

  • For $70\%$ of the test cases, $n < 100$.
  • For $100\%$ of the test cases, $3 \le n \le 10^4$, and the numbers in the given target ring do not exceed $10^9$.

Notes

This problem is translated from COCI2007-2008 CONTEST #2 T5 KEMIJA.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 5 5 5
样例输出
2 1 2