num = int(input())
if num % 2 == 0:
    lis = [i for i in range(1, num + 1) if i % 2 == 1]
    lis1 = []
    for n in lis:
        lis1 += [num ** 2 - n]
        lis1 += [num ** 2 + n]
elif num % 2 == 1:
    lis = [i for i in range(1, num + 1) if i % 2 == 0]
    lis1 = [num ** 2]
    for m in lis:
        lis1 += [num ** 2 - m]
        lis1 += [num ** 2 + m]
lis1.sort()
lis2 = "+".join(list(map(str, lis1)))
print(lis2)
虽然能过但是题目难度是简单,看了一眼大佬的解法,tnnd数学白学了
4^3 = (4x3)13+15+17+19(4x5)
5^3 = (5x4)21+23+25+27+29(5x6)
n = int(input())
lis = [str(i) for i in range(n*(n-1), n*(n+1)) if i % 2 == 1]
lis1 = "+".join(lis)
print(lis1)

不过时间上上面的快一点