1140: 台阶问题

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:31 Solved:12

Description

小明上楼梯,一步可以迈1个台阶、2个台阶或者3个台阶,现共有n(1<=n<=30)个台阶。请编程计算他所有可能的走法。

Input

总台阶数量n(1<=n<=30)

Output

所有可能的走法,每行一种走法

Sample Input Copy

4

Sample Output Copy

1 1 1 1
1 1 2
1 2 1
1 3
2 1 1
2 2
3 1

Source/Category