You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
483 B

2 years ago
#include<iostream>
using namespace std;
int main() {
int k, h = 0, p = 0;
cin >> k;
if (k == 1) { cout << 1; }
for (int i = 1; i <= k; i++)//i表示第p天获得了i个金币
for (int j = 1; j <= i; j++)
if (p >= k) {
cout << h;
return 0;
}//如果超过第k天输出金币数
else {
h += i, p++;//统计金币数和天数
}
return 0;
}