Submit | All submissions | Best solutions | Back to list |
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.
Added by: | Tomek Czajka |
Date: | 2005-05-03 |
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 |
hide comments
|
||||||||||||||
2014-06-29 17:16:41 Shubham Singh
What is meant by rounding the number?? |
||||||||||||||
2014-06-27 21:37:35 code_do
@Tomek I am getting SIGABRT error in this code.Please help me with this code <snip> Last edit: 2022-08-09 22:49:19 |
||||||||||||||
2014-06-21 22:21:24 Abhijeet Dubey
silly mistake in taking input caused me 6 NZEC errors...finally accepted... my first DP problem... Last edit: 2014-06-21 22:24:39 |
||||||||||||||
2014-06-20 20:30:37 AnilKumar
Getting segmentation fault if n = 10^9 till n = 10^8 its working fine...Any Suggestions??? P.S : coded in C |
||||||||||||||
2014-06-20 20:18:52 AnilKumar
@Gireek for n=999 ans - 1370 |
||||||||||||||
2014-06-20 20:08:40 LUCIFER
please tell the answer for n=999 |
||||||||||||||
2014-06-14 05:23:52 L
First DP... AC in first attempt!!!! time =0.00sec mem 2.8MB ..... |
||||||||||||||
2014-06-01 16:04:10 Sumit Kushwaha
Dont worry about no of inputs. Just take a single input produce output. Repeat! |
||||||||||||||
2014-05-31 13:33:57 Sumit Kushwaha
How many inputs we need to take? |
||||||||||||||
2014-05-17 22:00:43 pvkcse
first program in c++ here...Got AC... |