题解 | [NOIP2015]金币
[NOIP2015]金币
https://www.nowcoder.com/practice/8f71f5670e6a45118d24d13868a2da9e
day = int(input()) coin_num = 0 belong = ((1 + 8 * day) ** 0.5 -1) / 2 n = ((1 + 8 * day) ** 0.5 -1) // 2 coin_num = (n * (n + 1) * (2 * n + 1)) / 6 if belong != n: coin_num += (day - (1 + n) * n / 2) * (n + 1) print(f'{coin_num:.0f}')