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.
21 lines
589 B
21 lines
589 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
int k; //第k天付出多少个金币
|
|
int coin; //多少个金币
|
|
int day = 1; //现在是第几天
|
|
int main() {
|
|
cin >> k;
|
|
for (int i = 1;; i++) { //此层循环描述的是第几轮
|
|
for (int j = 1; j <= i; j++) { //此层循环描述是当前轮的第几天
|
|
//金币数增加p个(轮次号个)
|
|
coin += i;
|
|
if (day == k) {
|
|
cout << coin << endl;
|
|
return 0;
|
|
}
|
|
day++;
|
|
}
|
|
}
|
|
return 0;
|
|
} |