@Bittu: There are 3 cases:
1. If n = 2^b - 1, then put $1, $2, $4, ..., $(2^(b-1)) in the boxes.
2. If n < 2^b - 1, then there is some freedom in how to distribute the
dollars into the boxes. One way that works is to put $1, $2, $4, ...
(powers of two dollars) into as many boxes as you can, and then
distribute the remaining dollars among the remaining boxes in any way
that you want.
3. If n > 2^b - 1, then there is no distribution of the dollars that
works. This is the restriction on b and n that you asked about.

An example of case 2 is b = 4 and n = 10. Put $1, $2, $4, and $3 into
the boxes.

Dave

On Mar 4, 4:11 pm, bittu <[email protected]> wrote:
> “You have b boxes and n dollars. If I want any amount of money from 0
> to n dollars, you must be able to hand me 0 to b boxes so that I get
> exactly what I request.” The two questions were “What are the
> restrictions on b and n, and how is money distributed among the
> boxes?”
>
> Thanks
> Shashank

-- 
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?hl=en.

Reply via email to