You are not logged in. Please login at www.codechef.com to post your questions!

×

Math_Conversion

Please me with Code of this Problem in java or c or c++

You have a block of platinum that can be exchanged in your bank either for cash or for smaller blocks of platinum. If you exchange a block of m grams, you get three blocks of weight m/2, m/3 and m/4 grams each. You don't get any fractional part, as the division process rounds down the value. If you exchange the block of platinum for cash, you get m units of currency. You can do any number of exchanges for smaller blocks or currency. Given the value of a block in grams as input, write a program that would print the largest possible currency value that you can receive as the output. Assume that the maximum value of a block that can be given as an input is 1,000,000,000 grams and the minimum value is 2 grams.

e input 1 12 Sample output 1 13 Explanation: You can change 12 into blocks of 12/2 = 6, 12/3 = 4 and 12/4 = 3, and then exchange these for 6 + 4 + 3 = 13 units of currency 3

Sample input 2 2 Sample output 2 2 Explanation: If you exchange 2 grams into smaller blocks, it gives 2/2 = 1, 2/3 = 0, 2/4 = 0, only 1 unit. Instead, you can directly exchange the block for 2 units of currency.

This question is marked "community wiki".

asked 15 Oct '15, 23:43

coolpooo's gravatar image

0★coolpooo
1124
accept rate: 0%


I have a doubt, might be irrelevant. Why is the name Math_conversion?

The question is similar to https://www.codechef.com/problems/COINS

Are you asking this problem? If so, it requires simple recursive memorization.

I saw your profile. Is this the first problem you are solving? If so, I sincerely suggest you to try problems from easy section.

link

answered 24 Oct '15, 21:54

dragonemperor's gravatar image

3★dragonemperor
89321135
accept rate: 10%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×1

question asked: 15 Oct '15, 23:43

question was seen: 1,438 times

last updated: 24 Oct '15, 21:54

Related questions