Assume that you have a block weighing 40 kg and have tools to divide it as you want. Now, your task is to cut that block into 4 pieces such that only using those 4 pieces and a two-way balancing pan, you can measure any weight from 1 kg to 40 kg ? (You should be able to measure any weight like 1 kg, 2 kg, 3 kg upto 40 kg ).
Now since you have to divide it only into 4 pieces, so dividing it into 1, 2, 4 and 8 kg will not serve the task, as they will not be able to measure all the weights upto 40 kg.
So, what we can do is divide it into 4 blocks of weights 1 kg, 3 kg, 9 kg and 27 kg. Now, see how we can measure all the weights using it:
1 kg: 1 kg can be measured directly using block of 1 kg.
2 kg: To measure 2 kg, we can put 1 kg block with 2 kg and then put 3 kg block against these two, i.e., 2 + 1 = 3.
Similarly, 5 kg : It can be done using 5 kg + 1 kg + 3 kg = 9 kg.
7 kg : 7 kg + 3 kg = 1 kg + 9 kg.
Like this we can do for all the weights till 40 kg (40 = 1 + 3 + 9 + 27). Hence, the 4 weights required are 1 kg, 3 kg, 9 kg and 27 kg.
This article is contributed by Mrigendra Singh. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.