12445 - Cola Exchange   

Description

Source : Modified by Uva11150  

One day, you see the following special offer by the convenience store:

"3 + E empty bottle of Choco Cola exchange for a new one." 

E : After exchanging 10 new colas, E will increase by 1 (initial E  = 0)

Now you decide to buy some (say N) bottles of cola from the store. You would like to know the most colas you can get from them. 

Take N = 8 for example. At best, you will exchange 4 times and get 12 bottle in the end. (E = 0 since the number of exchange times less than 10)

Method 1 is the standard way: After finishing 8 bottles of cola, you have 8 empty bottles. Take 6 of them to the store and you get 2 new bottles of cola. Once you finish those 2 colas, you will have 4 empty bottles. You take 3 of them to the store for another 1 new cola. Finally, you have only 2 empty bottles in hand, so you cannot get any new cola. Hence, you have enjoyed 8 + 2 + 1 = 11 bottles of cola.

You can actually do better!
In Method 2, you can first borrow an empty bottle from your friend (?! Or the storekeeper??), then you can enjoy 8 + 3 + 1 = 12 bottles of cola! Of course, you need to return the remaining empty bottle to your friend(?! Or the storekeeper??).

 

In more complexity case, you need to handle the number of exchange times over 10. if the number of exchange times > 10, then you need to use 4 cola to exchange 1 cola, if the number of exchange times > 20, then you need to use 5 cola to exchange to 1 cola if the number of exchange times > 30, then you need to use 6 cola to exchange  1 cola ... and so on.

Note that: if you borrow bottles from your friend,  you must return the empty bottles at the end of exchange

Note that: If you are using visual studio, add #pragma warning(disable:4996) in the first line so that you can use scanf on your local machine.

 

Input

Input consists of several lines, each containing an integer N (1 ≤ N ≤ 6000).

Output

For each case, your program should output the maximum number of bottles of cola you can enjoy. You may borrow empty bottles from others, but if you do that, make sure that you have enough bottles afterwards to return to them.(the output string follow by an newline character)
Note: Drinking too much cola is bad for your health, so... don’t try this at home!! :-)

 

Sample Input  Download

Sample Output  Download

Tags




Discuss