Sand Castle X36488


Statement
 

pdf   zip

html

[r]

One of Roger’s favorite activities at the beach is building sand castles. Roger has a bucket that he can fill with wet sand and turn upside down to form a sand block. However, since the sand is slippery, the sand block will fall down unless it is placed on the beach itself, or on top of four stable blocks (as shown in the figure). Today Roger wants to build a sand castle that is as high as possible. Can you help him?

Input

A sequence of integers 0≤ N≤ 109, denoting the number of sand blocks that Roger has available to build his castle.

Output

For each input, a single line with an integer denoting the highest castle that Roger can build using that amount of sand blocks.

Public test cases
  • Input

    0
    1
    3
    5
    10
    15
    30
    50
    100
    1000000000
    
    

    Output

    0
    1
    1
    2
    2
    3
    4
    4
    6
    1441
    
  • Information
    Author
    Anders Jonsson
    Language
    English
    Official solutions
    Unknown.
    User solutions
    C++