用python做的,第八个测试点过不去,求大佬指教

P2669 [NOIP2015 普及组] 金币

LIEN666 @ 2021-03-30 14:54:09

K = int(input())

sum_gold = 0
lst = []
for i in range(1, K + 1):
    for index, value in enumerate(range(1, i + 1)):
        if (index + 1) <= K:
            sum_gold = i
            lst.append(sum_gold)

for index, value in enumerate(lst[:K]):
    if (index + 1) == K:
        sum_gold = sum(lst[:index + 1])
        print(sum_gold)

|