Problem Z: 打印锥形杨辉三角

Problem Z: 打印锥形杨辉三角

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 128 MB

Description

打印锥形杨辉三角

Input

5

Output

    1   
   1 1  
  1 2 1 
 1 3 3 1
1 4 6 4 1

Sample Input Copy

10

Sample Output Copy

             1             
            1 1            
           1 2 1           
          1 3 3 1          
         1 4 6 4 1         
       1 5 10 10 5 1       
      1 6 15 20 15 6 1     
    1 7 21 35 35 21 7 1    
   1 8 28 56 70 56 28 8 1  
1 9 36 84 126 126 84 36 9 1

HINT

n=int(input())
a=[[0]*(n+1) for i in range(n+1)]
a[0][0]=1
for row in range(1,n+1):
    for col in range(1,row+1):
        a[row][col]=a[row-1][col-1]+a[row-1][col]
L=len(' '.join([str(i) for i in a[n][1:n+1]]))
for i in range(1,n+1):
  print(' '.join([str(i) for i in a[i][1:i+1]]).center(L))