P2669(金币)
程序员文章站
2024-01-12 09:29:52
...
#include <bits/stdc++.h>
using namespace std;
int main() {
int k, total = 0, i = 1;
scanf("%d", &k);
while (k) {
for (int j = 1; j <= i; j++)
if (k > 0)
total += i, k--;
else {
printf("%d\n", total);
return 0;
}
i++;
}
printf("%d\n", total);
return 0;
}
上一篇: BZOJ2669