#include<bits/stdc++.h> using namespace std; int f(int n){ int r=0; if(n==1) r=1; else r=f(n-1)+n-1; return r; } int main(){ int h=0; for(int i=1;h<=5000;i++){ h=h+f(i); } cout<<h; return 0; } /************************************************************** Problem: 1146 User: hongjiaming Language: C++ Result: Accepted Time:4 ms Memory:2072 kb ****************************************************************/