You are given N number of weights that are all powers of 2. You are also given an item that weighs 1003 lbs.
(1) Exactly how many of those weights would be needed to balance the weight of the item if you could only use one of each weight?
(2) What's the fewest number of weights you can use to balance the weight of the item if there is an unlimited amount of each weight available to you?
(1) Exactly eight weights wil be required to balance the weight of the item.
These are: 512, 256, 128, 64, 32, 8, 2, 1 lbs
(2) These also happen to be the fewest number of weights that can be used to balance the weight of the item. This is so because it will always be possible to iteratively replace any pair of similar weights with a single higher weight till such time that not more than one of each weight remains.
There's a more efficient method possible, but this involves being allowed to use both pans rather than only one pan to place the weights, and I'm not sure if the problem permits it.
You can balance the pans with the use of four weights by placing a 1024 lb weight on one pan and the item along with 16, 4, & 1 lb weights on the other pan.
|
Posted by Sanjay
on 2003-06-23 12:51:32 |