COINS  Bytelandian gold coins
In Byteland they have a very strange monetary system.
Each Bytelandian gold coin has an integer number written on it. A coin n can be exchanged in a bank into three coins: n/2, n/3 and n/4. But these numbers are all rounded down (the banks have to make a profit).
You can also sell Bytelandian coins for American dollars. The exchange rate is 1:1. But you can not buy Bytelandian coins.
You have one gold coin. What is the maximum amount of American dollars you can get for it?
Input
The input will contain several test cases (not more than 10). Each testcase is a single line with a number n, 0 <= n <= 1 000 000 000. It is the number written on your coin.
Output
For each test case output a single line, containing the maximum amount of American dollars you can make.
Example
Input: 12 2 Output: 13 2
You can change 12 into 6, 4 and 3, and then change these into $6+$4+$3 = $13. If you try changing the coin 2 into 3 smaller coins, you will get 1, 0 and 0, and later you can get no more than $1 out of them. It is better just to change the 2 coin directly into $2.
hide comments
triangle7201:
20190723 01:38:48
For C++ users:


necrofool:
20190719 18:39:33
Even the brute force recursive solution is getting accepted. Time limit is 9 freaking seconds, Lmao! Last edit: 20190719 18:39:47 

rmcr714:
20190716 10:40:29
guys for those who r unable to understand the problem and saying how come 1000000000 can be 4233... instead of 100000333.. some value. please read the problem carefully, say if u have 12 as input and u do 12/2 then 12/3 then 12/4 we get 6 ,3,4 respectively right ,now the point is to divide 6,3,4 into 3 parts like 6/2,6/3,6/4 same for 3 and 4 and see if the divisions are greater than 6,3,4 and return the max value. Its like a recursive thing and computing the same value again and again so its a dp problem ,try this approach and youll be able to see the difference in the answers who r doing it the wrong way. This msg was for those who didnt understand the problem clearly ,hope this helps someone ,thx 

maximum_01:
20190712 21:12:15
how to take input as we dont know how many inputs are there?


himmu_04:
20190709 17:24:17
How to take input in python ?? 

am_venkat_2000:
20190701 23:03:38
For Java users,


vurise18:
20190626 19:52:20
cant understand the question


cenation007:
20190625 21:01:24
Easy peasy lemon squeezy


puszek215:
20190619 09:34:34
Python 3.5 solved with recursion and @memoize decorator. 

chinmay_sharma:
20190618 15:01:07
AC in one go

Added by:  Tomek Czajka 
Date:  20050503 
Time limit:  9s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: NODEJS PERL6 VB.NET 
Resource:  Purdue Programming Contest Training 