Other Programming and Technical Category

Your friend wants to set up a small scale industry which produces weights used in a
physical balance.

His customers are the shopkeepers located in his state. Each shopkeeper wants a set of
weighing objects using which he can produce all integer weights in range [1,n], where n may
vary for each shopkeeper. For a small grocery shop, n could be upto 50 Kg, and for a whole
sale shopkeeper n could be 1000 Kg. For a given n, a trivial solution is that the shopkeeper
keeps n weighing objects each of weight one kilogram. But it is very cumbersome to use and
manage so many weighing objects. So he wants the minimum number of weighing objects
using which he can weigh any object whose weight is in the range [1, n]. Such a set of
weighing objects is called a Min-weighing-objects(n) set. Such set need not be unique. For
example, {1, 3, 5} as well as {1, 2, 6} can serve to be a Min-weighing-objects(9) set.
Your friend wants to expand his business. So he wants to ensure that his customers get
full satisfaction. In particular, for a given n, he would like to present to the shopkeeper all
possible Min-weighing-objects(n) sets. The shopkeeper can place an order for the set of his
choice. Finally your friend delivers weights of that set to the shopkeeper. Your friend is
unable to come up with any solution to this problem. He approaches you with this problem.
Solve this problem. More formally, he wants you to write a program which for a positive
integer n, enumerates all Min-weighing-objects(n) sets.

Read Solution (Total 2)

Other Other Question

I live on this Earth for millions of years.iam immortal.i can live wherever i want,no one can question me.who am i? 3+5+6=151872
5+5+6=253094
5+6+7=303585
5+5+3=251573

9+4+7=?