Problems
What is a Pascal triangle? A Pascal triangle is a triangle in which each number is obtained by adding the values of the upper-left and upper-right positions, as shown in Table 1 below.
Write a program that, given the height π of a Pascal triangle and a type π, prints the triangle in the specified format.
Conditions
The appearance of the Pascal triangle depends on the type π, as shown in Table 2.
Input
Two integers are given: the triangle height π (1 β€ π β€ 30) and the type π (1 β€ π β€ 3).
Output
Print the Pascal triangle according to the given height π and type π.
Separate numbers with a single space.
Example #1
5 1
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
Example #2
4 2
1 3 3 1
1 2 1
1 1
1
Example #3
6 3
1
5 1
10 4 1
10 6 3 1
5 4 3 2 1
1 1 1 1 1 1
Tag
Source
JUNGOL