python求助!90分

P2669 [NOIP2015 普及组] 金币

EC75 @ 2021-12-10 19:47:40

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)

|