复赛1:金币

洛谷:P2669

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/**************************************************************** 
 * Description: 2015年复赛第一题,金币
 * Author: Alex Li
 * Date: 2022-10-06 08:05:45
 * LastEditTime: 2023-10-30 10:32:36
****************************************************************/
#include <iostream>
using namespace std;

int main(){
    int k,s=0,t=0;
    cin>>k;

    for (int i =1; i <=150; i++){
        for (int j =1 ; j <=i; j++){                       
             t++;
             if(t>k)break;
             s=s+i;
        }
    }
    cout<<s;
    
}
Scroll to Top