题解 | #[NOIP2015]金币#
[NOIP2015]金币
https://www.nowcoder.com/practice/8f71f5670e6a45118d24d13868a2da9e
#include <stdio.h>
int main() {
int k = 7, sum = 0, day = 0;
while (scanf("%d", &k) != EOF) {
// 金币数
for (int i = 1; ; i++) {
int temp = i;
// 金币重复天数
for (int j = i; temp > 0; temp--) {
sum += j;
day++;
if (day == k) {
break;
}
}
if (day == k) {
break;
}
}
}
printf("%d\n", sum);
return 0;
}