题解 | #[NOIP2015]金币#
[NOIP2015]金币
http://www.nowcoder.com/practice/8f71f5670e6a45118d24d13868a2da9e
k = int(input())
sum = 0
cnt = 0
i = 1
while cnt < k:
cnt += i
sum += i*i
i += 1
sum -= (i-1)*(cnt-k)
print(sum)
[NOIP2015]金币
http://www.nowcoder.com/practice/8f71f5670e6a45118d24d13868a2da9e
k = int(input())
sum = 0
cnt = 0
i = 1
while cnt < k:
cnt += i
sum += i*i
i += 1
sum -= (i-1)*(cnt-k)
print(sum)
相关推荐