CF 492A - Vanya and Cubes
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.
Examples
input
1
output
1
input
25
output
4
Note
Illustration to the second sample:

------------------------------------------
Vanya 有 n 個立方體。 他決定用它們建造一座金字塔。 Vanya想要建造金字塔如下:金字塔的頂層必須由1個立方體組成,第二層必須由1?+?2?=?3個立方體組成,第三層必須由1?+?2?+?3?=?6個立方體組成,依此類推。 因此,金字塔的第 i 層必須有 1?+?2?+?...?+?(i?-?1)?+?i 個立方體。
Vanya 想知道他使用給定的立方體可以制作的金字塔的最大高度是多少。
輸入
第一行包含整數(shù) n (1?≤?n?≤?104) — 給予 Vanya 的立方體數(shù)量。
輸出
在一行中打印金字塔的最大可能高度。
-------------------------------------
下面是代碼:
這里面++i跟i++沒理清楚,結(jié)果錯了一次,++i是當前循環(huán)就加上1,i++是下個循環(huán)再加1的。