Extension and summary of gold segmentation problem in Microsoft's face test | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Date: 2002.03.08 | | Author: seraph chutium | | HomePage: http://com.6to23.com/ | | | ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ State: Write more rush, basic ideas are definitely true, if there is a mistake in the expression, if you have a serious logic error, you hope that everyone is correct. (You can come to the message book message to discuss the friends who have learned the binary algorithm can have passed this article, just to give a small case to talk about the relationship between 2 ^ N and the binary. Programming masters must not be taken for this fee. If you can fortunately, you can write a few times more than this. 1. The test analysis extension in the "Programmer" magazine test is published in the topic of Microsoft to interview: Workers work for you for 7 days, returned to a gold bars, must pay for them every day, and can only Double twice, how will you pay? Let's take a look at my own question: How to put 7 gold in 3 boxes, so that I can take a whole box? We can discover very much, such two topics are essentially the same, and their answers are also the same. That is, the gold bars are cut into 1, 2, 4, or to put 7 gold in the box with 1, 2, 4 pieces, respectively. This topic is relatively simple, but if you use the same scenario, do you have such a question? Workers working for you for 365 days, returned to a gold bar, must pay them a paragraph every day, and only 9 times, how will you pay? Or how to put 365 gold into 9 boxes, so that I can take a whole box? With such a number may be more difficult to see the mystery, we change this group: .......................................................... How will you pay? Or how to put 255 gold in 8 boxes, can you take a whole box? Seeing 8 and 255 The two numbers will think that you will realize that 255 = 2 ^ 8-1 will be immediately realized. So what is the relationship between such a set of numbers and gold sections? Let's take a look at the two more complex answers to the topic. 365 days: Sutraction 8 times is equal to dividing the original gold bars into 9 boxes into 9 boxes, then it is: I: 1, II: 2, III: 4, IV: 8, V: 16, VI: 32, VII: 64, VIII: 128, IX: 365-255 = 110. 255 days: 7 times is equal to dividing the original gold bars into 8 paragraphs into 8 boxes, then its branch is: i: 1, II: 2, III: 4, IV: 8, V: 16, VI: 32, VII: 64, VIII: 128. 2. Summary of this topic, we don't really find that M box can complete the above The "gold" number installed in the process is 2 ^ m-1. At this time, the "gold" number in the box is: 2 ^ 0, 2 ^ 1, 2 ^ 2, ... 2 ^ (m-1). Thus we can export for any natural number N, can divide it into several copies, so that we can remove any quantity throughout. There must be a maximum 2 ^ n value in (0, n). This natural number N can be divided into N 1, each in each of: 2 ^ 0, 2 ^ 1, 2 ^ 2, ... 2 ^ (n-1), n-2 ^ n 3. Search for the source, then this is why? We take the simplest 7, 8, 15, 16 to make a description.