There is a 100-storey building, an egg from the nth floor and above the floor will break, on the nth floor below the floor will not break. Give you 2 eggs, design a solution to find N, and ensure that in the worst case, minimize the number of egg drops.
Set the worst case of the number of K, if the first egg in the X-layer is broken, then the second egg should start from the 1th level to try to x-1 layer, the worst also try x-1 times, the total number of tests for 1+ (x-1) = k,x=k;
If the first egg is not bad for the first time in the X layer, the second break, at this time has been tested 2 times, then the second egg is the worst able to test k-2 times, set the second broken layer is Y, then the second egg should start from the X+1 layer test to y-1 layer, for k-2 times, namely (Y-1)-(x+1) +1=k-2 Because X=k, so y=2*x-1 =x+ (x-1) layer;
If the first egg is broken in the third time, ditto for the third time should be in x+ (x-1) + (x-2) layer
Up to x+ (x-1) + (x-2) +...+1 layer, should be greater than or equal to the total floor 100, i.e.
x + (X-1) + (x-2) + ... + 1 >= 100
(x+1) *X/2 >= 100
x=14;
So test up to 14 times, first on 14 levels, second at 27, and so on 14, 27, 39, 50, 60, 69, 77, 84, 90, 95, 99, 100;
100 Floors of 2 eggs