#P12206. Pyramid of Marbles
Pyramid of Marbles
Pyramid of Marbles
Little Blue has a collection of marbles and is fascinated by pyramid shapes. In a pyramid of height (h), the number of marbles required is given by the formula (f(h)=\sum_{i=1}^{h}\frac{i(i+1)}{2}). For example:
(f(1)=\frac{1\times2}{2}=1)
(f(2)=1+\frac{2\times3}{2}=1+3=4)
(f(3)=1+3+\frac{3\times4}{2}=1+3+6=10)
(f(4)=1+3+6+\frac{4\times5}{2}=1+3+6+10=20)
Given an integer (n) representing the total number of marbles available, determine the maximum height (h) of a pyramid that can be built such that (f(h)\le n).
inputFormat
The input consists of a single integer (n) ((1\le n\le 10^{12})), representing the number of marbles available.
outputFormat
Output a single integer, the maximum height (h) of the pyramid that can be built.
sample
1
1