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