100 atcoder#ABC133D. [ABC133D] Rain Flows into Dams
[ABC133D] Rain Flows into Dams
Score : points
Problem Statement
There are mountains in a circle, called Mountain , Mountain , , Mountain in clockwise order. is an odd number.
Between these mountains, there are dams, called Dam , Dam , , Dam . Dam () is located between Mountain and (Mountain is Mountain ).
When Mountain () receives liters of rain, Dam and Dam each accumulates liters of water (Dam is Dam ).
One day, each of the mountains received a non-negative even number of liters of rain.
As a result, Dam () accumulated a total of liters of water.
Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.
Constraints
- All values in input are integers.
- is an odd number.
- The situation represented by input can occur when each of the mountains receives a non-negative even number of liters of rain.
Input
Input is given from Standard Input in the following format:
Output
Print integers representing the number of liters of rain Mountain , Mountain , , Mountain received, in this order.
3
2 2 4
4 0 4
If we assume Mountain , , and received , , and liters of rain, respectively, it is consistent with this input, as follows:
- Dam should have accumulated liters of water.
- Dam should have accumulated liters of water.
- Dam should have accumulated liters of water.
5
3 8 7 5 5
2 4 12 2 8
3
1000000000 1000000000 0
0 2000000000 0