'commit'
This commit is contained in:
20
TangDou/LuoGuBook/P2669.cpp
Normal file
20
TangDou/LuoGuBook/P2669.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user