CF 280A. Vanya and Cubes(div2)

http://codeforces.com/contest/492/problem/A

Vanya got n cubes. He decided to build a pyramid from them. Vanya wants to build the pyramid as follows: the top level of the pyramid must consist of 1 cube, the second level must consist of 1?+?2?=?3 cubes, the third level must have 1?+?2?+?3?=?6 cubes, and so on. Thus, the i-th level of the pyramid must have 1?+?2?+?...?+?(i?-?1)?+?i cubes.

Vanya wants to know what is the maximum height of the pyramid that he can make using the given cubes.

Input

The first line contains integer n (1?≤?n?≤?104) — the number of cubes given to Vanya.

Output

Print the maximum possible height of the pyramid in the single line.

Sample test(s)
input
1
output
1
input
25
output
4
Note

Illustration to the second sample:

CF 280A. Vanya and Cubes(div2) - 风未定 - Principal Guan

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define maxn 10000+5
#define ull unsigned long long
#define ll long long
#define reP(i,n) for(i=1;i<=n;i++)
#define rep(i,n) for(i=0;i#define cle(a) memset(a,0,sizeof(a))
#define mod 90001
#define PI 3.141592657
#define INF 1<<30
const ull inf = 1LL << 61;
const double eps=1e-5;

using namespace std;

bool cmp(int a,int b){
return a>b;
}
int t;
int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
cin>>t;
int sum=0;
for(int i=1;;i++)
{
sum+=(i*i+i)/2;
if(sum==t){cout< if(sum>t){cout< }
return 0;
}


暴力一下就行了

你可能感兴趣的:(CF 280A. Vanya and Cubes(div2))