Files
python/LuoGu/RuMen/P2669.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

19 lines
483 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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;
}