Here is the problem statement
This is a probelm of recursion and memorization at teh same time. Here is the main question, suppose we decided to divide our coin of value N into N/2 N/3 and N/4. Now we have 3 coins, the main question says," Do I need to divide the new coins ito smaller ones for making a bigger profit?" This calls for recursion. For speeding up the time we wil also keep the solutions which we already found so that next time if we come across to the number we already calculate ,we can easily add already calculated answer. Checkthe source code for a better understanding.
your code isn't downloadable, the download link is broken..
ReplyDeleteHI. I fixed it, now there is an embeded version of the code on this page.
DeleteI just came here to know how to take the inputs and what will be the stopping criteria? i mean how to know inputs are over and now we need start printing the solution?
ReplyDeletePlease reply in english only. (no code :)
Delete)
It is not possible to do when using console input output however if the program is reading from an input file there are some commands for it, every language has it's own. It sounds like the following
Deletewhile( input is not over)
proceed;
In C++ you can use
while(cin)
{
}
which means while there is somethhing to cin (read)
Hey sumit,
DeleteIn C you can use MACRO
while(scanf("%lld",&n)!=EOF)
{
//code
}
Hey, could you please explain me the significance of the line 'long long c=x-x%12;'? Pretty confused, whether it is even required.
ReplyDeletewhy is c compared with 0 in line 14
ReplyDelete