Triangle Addition
Time limit2sMemory limit2048 MB
Given a sequence, the task repeatedly sums adjacent pairs to build a triangle and prints each row of the triangle.
- Level
Easy1 of 10
- Topics
- Simulation, Implementation
- Solved
- No attempts yet
Statement
N integers are written on a blackboard from left to right.
The i-th integer from the left is A_i.
For the integer sequence on the blackboard, repeat the following operation.
Operation
Let k be the length of the integer sequence in the bottom row of the blackboard. Referring to the values of this sequence, write below it a new sequence of length k - 1.
For each i = 1, 2, ..., k-1, the i-th integer of the new sequence is the sum of the i-th and (i+1)-th integers of the referenced sequence.
Perform this operation N-1 times. Find all the integer sequences written on the blackboard.
Input
The input is given in the following format.
N
A1 A2 … AN
Output
Print the integer sequences written on the blackboard in the N-1 operations, one sequence per line in N-1 lines.
On the i-th line (1 ≦ i ≦ N), print the sequence written in the i-th operation, separated by spaces.
Print only the answer. Do not print any prompt or other text.
Constraints
2 ≦ N ≦ 10.1 ≦ Ai ≦ 10(1 ≦ i ≦ N).- All input values are integers.