题解 | #蛇形矩阵#
蛇形矩阵
https://www.nowcoder.com/practice/649b210ef44446e3b1cd1be6fa4cab5e
''' 1*1 1*2 1*3 1*4 1*5 1 3 6 10 15 i*(i+1)/2 2*1 2*2 2*3 2*4 2 5 9 14 -1 3*1 3*2 3*3 4 8 13 -1 4*1 4*2 7 12 -1 5*1 11 -1 ''' n=int(input()) for i in range(1,n+1): for j in range(i,n+1): print(int(j*(j+1)/2-(i-1)),end=' ') print()