#K89332. Pascal's Triangle Generation

    ID: 37507 Type: Default 1000ms 256MiB

Pascal's Triangle Generation

Pascal's Triangle Generation

In this problem, you are asked to generate the first n rows of Pascal's Triangle. Pascal's triangle is a triangular array of the binomial coefficients. The entry in the i-th row and j-th column is \(\binom{i}{j}\), where indexing starts at 0.

The first row is simply "1". Each subsequent row starts and ends with 1, and every other element is the sum of the two numbers directly above it in the previous row.

For example, when \(n = 5\), the Pascal's Triangle looks like:

[ 1\ 1\ 1\ 1\ 2\ 1\ 1\ 3\ 3\ 1\ 1\ 4\ 6\ 4\ 1 ]

Your task is to read an integer \(n\) from standard input and output the first \(n\) rows of the triangle. If \(n = 0\), output nothing.

inputFormat

The input consists of a single integer \(n\) (\(0 \leq n \leq 30\)), which represents the number of rows of Pascal's Triangle to generate. The input is provided via standard input.

outputFormat

Output \(n\) lines corresponding to the rows of Pascal's Triangle. In each row, the numbers are separated by a single space. If \(n = 0\), output nothing.

## sample
0