There is a 100-storey building that gives you two identical glass balls. If you start from a certain level, drop the glass ball and smash it. So how to use the hands of the two ball, what best strategy to know this critical layer is the first layer?

Source: Internet
Author: User

The title has a 100-storey building that gives you two identical glass balls. If you start from a certain level, drop the glass ball and smash it. So how to use the hands of the two balls, with what best strategy to know this critical layer is the first layer???

Each time must be from the low floor to the high floor to try, until the floor f (k), the first ball has been broken down, record the last attempt on the floor for F (k-1), on this floor, the glass ball will not be broken, so next to try F (k-1) +1,f (k-1) +2,f (k-3) +3, ... Knowing that there is a broken floor, this floor is the solution, the worst is to reach F (k)-1 floor.

The next solution is easy to come up with: since the first step (to determine the critical section) of the number of throws is unavoidable, we let the second step (determine the critical layer) of the number of throws as the number of first steps increase and decrease. The number of throws in the first step is increased one at a time, so let's throw the second step down one at a time. Assuming that the first throw of the layer is F, into a mathematical model, f+ (f-1) +...+2+1 means to guess from F, each increment is more than the previous amount minus 1 of the case, the last guess of the number (that is f+ (f-1) +...+2+1), according to the proposed f+ (f-1) +...+2 +1>=99, F (f+1)/2>=99 (the first Test point selection 100 layer is meaningless, will inevitably break, so there is no test value, so the first Test point K is a number of 1-99), the solution of the result is equal to 14. The floors on which the first eggs were dropped were 14, 27, 39, 50, 60, 69, 77, 84, 90, 95, 99.

Why is f+ (f-1) +...+2+1>=99 in front? The first is to determine the critical section of the segment, we want to ensure that no matter which critical section of the egg is broken down to determine the number of times are the same, so it is necessary from the bottom to the top of each segment is 1 less than the length of the previous paragraph, and the total length of all segments is 99 (not required to be 100 because if the It doesn't have to be judged).

Gold Analysis: I come to explain an inequality to the right why is 99, in fact, using 99 or 100 The final result is the same, only 99 explain the profound understanding, because if you have already reached the 99 floor, you can glass ball or not broken, then the answer is 100, so 100 do not have to guess, If you talk about the relationship between 99 and 100 in the interview, it means that you are smart enough to use 100 or 99 to see the examiner, different people understand differently.

The first choice is 14, then the highest can be judged by the descending sequence above, 14, 27, 39, 50, 60, 69, 77, 84, 90, 95, 99, 102,104,105. Altogether is 14 times, finally is to 105, according to above 99 and 100 analysis, although is 14 times to guess, but last guessed 105, know if 105 still is not broken, then certainly 106,106 is the certainty, do not have to guess to know, so 14 times maximum can judge to 106, So 15 times it will start from 15, and if 107, then it will take 15 times.

For example, to 27 layers, glass broken, then to start from 15 a layer of the attempt, such as 26 is the solution, then guess the sequence is 14,27,15,16,17,18,19,20,21,22,23,24,25,26, altogether 14 times.

Note: This question at first did not understand, has been thinking why can not use the dichotomy method, the dichotomy is not up to 7 times can be done, and then thought for a while to the meaning of the two glass ball refers to, you can only use two glass ball to judge the glass ball broken off the critical floor, if using dichotomy, The first step is on the 50 floor. Then you are so bad, you can only start from the first layer to throw, to make 50 judgments, (if you continue to throw at 25, the last glass ball is broken again you do not have the ball can be used) so the dichotomy is not good here.

Then we can just like the above to use the first ball to determine an interval, and then within the interval from the bottom of the network to judge the

There is a 100-storey building that gives you two identical glass balls. If you start from a certain level, drop the glass ball and smash it. So how to use the hands of the two ball, what best strategy to know this critical layer is the first layer?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.