This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#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++;//统计金币数和天数
}