题解 | #[NOIP2015]金币#
[NOIP2015]金币
http://www.nowcoder.com/practice/8f71f5670e6a45118d24d13868a2da9e
BC96 [NOIP2015]金币
思路:
step1:先算整三角形的,再算多余的,最后累加;
代码如下:
n = int(input())
count = 0
day = 0
for i in range(1,n+1):
if (1 + i) * i / 2 <= n:
count += i * i
day = i
else:
break
count += (day + 1) * (n - (1 + day) * day / 2)
print(int(count))