2 eggs on 100 floor

Source: Internet
Author: User

There is a 100-story tall building with the same hardware and software level but two unknown eggs, the two eggs are required to determine which layer is the highest position where the eggs can safely fall with the minimum number of times. The eggs may break down on the first floor or even the fifth floor.


If the layer-l eggs are not broken, and the layer-L + 1 is broken, the layer-L is desired. Because there are only two eggs, the target layer must be measured in a limited number of times after the first egg is broken.


Test an intermediate state. Assume that the minimum number of times is C.

Previously, the C0 (C0 <c) layers were tested as l0, And the C0 + 1 layers were tested as L1. the first eggs were broken. Then the second egg is measured from the l0 + 1 layer of the L1-1 layer, may need to test (L1-1)-(l0 + 1) times, the limit for this number of times is smaller than C-(C0 + 1 ). From this status, we can see that the range of floor C0 + 1 should be 1 less than that of floor C0 (for example, if the range of floor C0 is 28 to 40, the C0 + 1 time is 41 to 52 .). Similarly, if you set the first floor to K, you can obtain the following solution:

K + (K-1) + (K-2) +... + (K-C + 2) + (K-C + 1)> = 100; the last time the floor range should be 1, so K should be equal to C. So the formula is changed

K + (K-1) + .. + 1> = 100; that is, K (k + 1)/2> = 100; k is 14, so the minimum number of times is 14, that is, the first test started from layer 14.


Alternatively, you can use the reverse method, that is, the last floor is 1, and the previous floor is added with 1 in sequence. The result is the same.


Finally, is there such an egg? It's not broken from the second floor!

----------------------------------------

It's a very simple thing. It's not easy to look at so many symbols.

This was previously written. If you think it is complicated, go to the Internet to find it. There should be many solutions.


2 eggs on 100 floor

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.