您的位置:首页 > 其它

A - Vanya and Cubes

2014-12-06 21:53 363 查看
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <stdlib.h>

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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: