Title: A. Vanya and Cubestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output
Vanya gotNCubes. He decided to build a pyramid from them. Vanya wants to build the pyramid as follows:the top level of the pyramid must consist of1Cube, the second level must consist of1?+?2?=?3cubes, the third level must has1?+?2?+?3?=?6cubes, and so on. Thus, theI-th level of the pyramid must has1?+?2?+?...? +? (i?-? 1)? +? I Cubes.
Vanya wants to know, the maximum height of the pyramid, the 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
Sample Test (s) input
1
Output
1
Input
25
Output
4
Note
Illustration to the second sample:
There's nothing to say. Simulate a bit, and WA should not be.
#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <vector > #include <queue> #include <stack> #include <cassert> #include <algorithm> #include < cmath> #include <set> #include <limits> #include <map>using namespace std; #define MIN (A, B) ((a) < (b)? (a): (b) #define MAX (A, B) ((a) > (b)? (a): (b) #define F (i, n) for (int (i) =0; (i) < (n), + + (i)) #define REP (I, S, T) for (int (i) = (s);(i) <= (t), + + (i) #define UR EP (I, S, T) for (int (i) = (s);(i) >= (t);-(i)) #define REPOK (I, S, T, O) for (int (i) = (s);(i) <= (t) && (o); + + (i)) # Define MEM0 (Addr) memset ((addr), 0, sizeof ((addr))) #define PI 3.1415926535897932384626433832795#define Half_pi 1.5707963267948966192313216916398#define maxn 100000#define maxm 10000#define MOD 1000000007typedef Long Long ll;const Double maxdouble = Numeric_limits<double>::max (); const double EPS = 1e-10;const int INF = 0x7fffffff;int Main () { int n; CIN >> N; int ans = 0; int base = 1; while (n >= base) {++ans; n-= base; Base + = ans+1; } cout << ans; return 0;}
Codeforces Round #280 (Div. 2) A