题解 | #蛇形矩阵#
https://www.nowcoder.com/practice/649b210ef44446e3b1cd1be6fa4cab5e
n = int(input()) sum1 = 0 sum2 = 1 x = 999999999 for i in range(1, n + 1): if i >= 2: x = sum1 - n + 1 print() sum1 = sum2 sum2 = sum2 + i for j in range(1, n + 1): if sum1 <= x: print(sum1, end=" ") sum1 = sum1 + j + i