题解 | #[NOIP2015]金币#
[NOIP2015]金币
https://www.nowcoder.com/practice/8f71f5670e6a45118d24d13868a2da9e
#include<stdio.h> int main() { int input; int sum = 0; int n = 1; scanf("%d", &input); while (input != 0) { input -= n; if (input >= 0) { sum += n * n; n++; } else { input += n; sum += input * n; break; } } printf("%d", sum); return 0; }