

Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
N 個の駅、駅 1, 駅 2, \ldots, 駅 N が直線上にこの順に並んでいます。
ここで、1\leq i\leq N-1 について、駅 i と駅 (i+1) の間の距離は D_i です。
1\leq i<j\leq N をみたす整数の組 (i,j) それぞれについて、駅 i と駅 j の間の距離を求めてください。
なお、出力形式については出力の欄を参照してください。
制約
- 2 \leq N \leq 50
- 1 \leq D_i \leq 100
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N D_1 D_2 \ldots D_{N-1}
出力
N-1 行出力せよ。
i 行目 (1\leq i\leq N-1) には、(N-i) 個の整数を空白区切りで出力せよ。
i 行目の j 番目 (1\leq j\leq N-i) には、駅 i と駅 (i+j) の間の距離を出力せよ。
入力例 1
5 5 10 2 3
出力例 1
5 15 17 20 10 12 15 2 5 3
各駅の間の距離は次のようになります。
- 駅 1 と駅 2 の間の距離は 5 です。
- 駅 1 と駅 3 の間の距離は 5+10=15 です。
- 駅 1 と駅 4 の間の距離は 5+10+2=17 です。
- 駅 1 と駅 5 の間の距離は 5+10+2+3=20 です。
- 駅 2 と駅 3 の間の距離は 10 です。
- 駅 2 と駅 4 の間の距離は 10+2=12 です。
- 駅 2 と駅 5 の間の距離は 10+2+3=15 です。
- 駅 3 と駅 4 の間の距離は 2 です。
- 駅 3 と駅 5 の間の距離は 2+3=5 です。
- 駅 4 と駅 5 の間の距離は 3 です。
よって、上記のように出力します。
入力例 2
2 100
出力例 2
100
Score : 200 points
Problem Statement
There are N stations, station 1, station 2, \ldots, station N, arranged in this order on a straight line.
Here, for 1\leq i\leq N-1, the distance between stations i and (i+1) is D_i.
For each pair of integers (i,j) satisfying 1\leq i<j\leq N, find the distance between stations i and j.
For the output format, refer to the Output section.
Constraints
- 2 \leq N \leq 50
- 1 \leq D_i \leq 100
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N D_1 D_2 \ldots D_{N-1}
Output
Output N-1 lines.
On the i-th line (1\leq i\leq N-1), output (N-i) integers, separated by spaces.
The j-th integer on the i-th line (1\leq j\leq N-i) should be the distance between stations i and (i+j).
Sample Input 1
5 5 10 2 3
Sample Output 1
5 15 17 20 10 12 15 2 5 3
The distances between stations are as follows:
- The distance between stations 1 and 2 is 5.
- The distance between stations 1 and 3 is 5+10=15.
- The distance between stations 1 and 4 is 5+10+2=17.
- The distance between stations 1 and 5 is 5+10+2+3=20.
- The distance between stations 2 and 3 is 10.
- The distance between stations 2 and 4 is 10+2=12.
- The distance between stations 2 and 5 is 10+2+3=15.
- The distance between stations 3 and 4 is 2.
- The distance between stations 3 and 5 is 2+3=5.
- The distance between stations 4 and 5 is 3.
Thus, output as shown above.
Sample Input 2
2 100
Sample Output 2
100