A - Vanya and Cubes

#include 
#include 
#include 
#include 
#include 

using namespace std;

int main()
{
    int n;

    while(scanf("%d",&n) != EOF)
    {
       if( n == 1)
       {
           printf("1\n");
           continue;
       }
       int cnt = 2;
       int ans = 1;
       int now = 1;
       int res = 1;
       while( ans < n)
       {
           now += cnt++;
           ans += now;
           res++;
       }
       if(ans == n)
        printf("%d\n",res);
       else
        printf("%d\n",res-1);
    }
    return 0;
}

你可能感兴趣的:(Codeforces,Round,#280,(Div.,2))