#P6340. Construct a Circular Ring with Adjacent Sum Property
Construct a Circular Ring with Adjacent Sum Property
Construct a Circular Ring with Adjacent Sum Property
Given a target circular ring \(T = [t_0, t_1, \ldots, t_{n-1}]\), construct a circular ring \(A = [a_0, a_1, \ldots, a_{n-1}]\) of \(n\) numbers such that for every index \(i\),
\[ a_{(i-1) \bmod n} + a_i + a_{(i+1) \bmod n} = t_i \]
Your task is to compute and output one valid ring \(A\) that satisfies this property.
inputFormat
The first line contains an integer \(n\) \((n \ge 3)\), the number of elements in the rings. The second line contains \(n\) space-separated integers, which represent the target ring \(T = [t_0, t_1, \ldots, t_{n-1}]\).
outputFormat
Output \(n\) space-separated integers representing the constructed ring \(A = [a_0, a_1, \ldots, a_{n-1}]\) that satisfies \(a_{(i-1) \bmod n} + a_i + a_{(i+1) \bmod n} = t_i\) for all \(i\).
sample
4
6 6 6 6
0 0 6 0