Codeforces Round #280 (Div. 2) A

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.