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
mayank220588:
20160526 20:52:37
how to ensure of two inputs only?


azam_9:
20160524 15:58:55
WA using vector..AC using maps..dont knw y?? 

Umesh Kumar Singla:
20160524 14:06:56
@vstepano Please correct the 4th test case to either 999 > 1370 or 9999(mind the four 9's) > 16615 

rohit_sharma:
20160524 14:05:55
Getting TLE for input > 10^8 on ideone... but it is taking 3 seconds on my local environment .. how is that possible ??? I thought time limit was 9 sec. Working with Java.


supertramp_sid:
20160523 09:34:55
Please check the data type you use. made a silly mistake by using int instead of long long. 

partha2717:
20160519 08:22:09
Silly mistake took 3 WA. :( 

vstepano:
20160518 08:56:36
Pay attention to the fact that the input doesnâ€™t contain the number of test cases!!!


satoruu:
20160517 03:23:35
That was awesome! 

jitendrakk:
20160513 17:10:58
Oh.. It was presentation error not wrong answer. 

jitendrakk:
20160513 16:46:49
I need some tricky edge cases? 
Added by:  Tomek Czajka 
Date:  20050503 
Time limit:  9s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: NODEJS PERL 6 VB.net 
Resource:  Purdue Programming Contest Training 