Let the denominations be D[] = {1000,500,100},
and amount be N.
Let C[] , denotes the count of each denomination.
for ( i=0 ; i < 2 ; i++) {
       C[i] = (N-1)/D[i] ;
       N = N - D[i]*C[i] ;
}
C[2] = N/D[2] ;

For N=4800, C[] = {4, 1, 8}
For N= 2000, C[] = {1, 1, 5}, as required.

Nice observation :) .

PS: Its the Newton who appreciated the falling apple. There aren't many who
really appreciate the happenings from our normal life. [?]
On Sat, Sep 19, 2009 at 11:50 PM, eSKay <[email protected]> wrote:

>
> for example: if I draw 2000, what I get is
> 1000+500+100+100+100+100+100.
>
> What algorithm can be used to decide how to break up the entered
> amount?
>
> >
>


-- 
Shishir Mittal
Ph: +91 9936 180 121

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

<<inline: 329.gif>>

Reply via email to