Problem:
A rock will be broken when it is dropped at a certain height. It will not be broken below the height, but it must be broken above the height. Now there are 4 stones and a 1000-storey building. The height of the broken stone needs to be determined. The minimum number of times can be tested.
Analysis:
We should consider this question in turn, that is, we can use a stone to throw B at most a certain number of layers X (A, B ).
Consider from the simplest stone. Obviously,
X (1, 1) = 1
X (1, 2) = 2
X (1, 3) = 3
.
X (1, I) = I
Consider two more stones.
X (2, 1) = 1
For X (2, 2), we can consider two possible causes when we throw the first time: broken and not broken.
If the stone is broken
1. We have one stone left.
2. We only need to check the floor below next time.
3. We have one chance left.
That is, we can also distinguish the following layer X.
If the stone is not broken
1. We have 2 stones left.
2. We only need to check the floor above next time.
3. We have one chance left.
That is, we can also distinguish the X (2, 1) layer above.
We know that X () = 1. So we threw it from the second layer for the first time. If the stone is broken, we will test the first layer. If the stone is not broken, we will test the third layer.
Therefore, it is possible to tell the difference between throwing two stones twice.
1 + x () = 1 + 1 + 1 = 3 layers.
We will consider
X (2, I)
For X (2, I), we think that when we throw the first time, there are two possibilities: broken and not broken.
If the stone is broken
1. We have one stone left.
2. We only need to check the floor below next time.
3. We have I-1 opportunities left.
That is, we can also distinguish the following x (1, I-1) layer.
If the stone is not broken
1. We have 2 stones left.
2. We only need to check the floor above next time.
3. We have I-1 opportunities left.
That is, we can also distinguish the above X (2, I-1) layer.
Then
X (2, I) = 1 + x (1, I-1) + X (2, I-1)
Next we will consider
X (I1, I2)
Similarly, for X (I1, I2), we still think like this. When we throw the first time, there are two possibilities: broken and not broken.
If the stone is broken
1. We have i1-1 stones left.
2. We only need to check the floor below next time.
3. We have i2-1 opportunities left.
If the stone is not broken
1. We have I1 rock left.
2. We only need to check the floor above next time.
3. We have i2-1 opportunities left.
That is
X (I1, I2) = 1 + x (i1-1, i2-1) + x (I1, i2-1)
Obviously
No matter how many stones you have, you can only test one layer at a time.
That is
X (I, 1) = 1.
In this way, the following table can be created:
Number of times: 1 2 3 04 05 06 007 008 009 010 011 012 013
Resolution layers:
One stone: 1 2 3 04 05 06 007 008 009 010 011 012 013
Two stones: 1 3 6 10 15 21 028 036 045 055 066 078 091
Three stone heads: 1 3 7 14 25 41 063 092 129 175 231 298
Four stones: 1 3 7 15 30 56 098 162 255 385 561 793 1092
Five stone heads: 1 3 7 15 31 62 119 218 381 637
Six stones: 1 3 7 15 31 63 126 246 465 847
That is to say, when four stones are used for 12 times, up to 793 layers can be distinguished, and up to 13 times can be distinguished by 1092 layers.
Answer:
A 1000-storey building,
4 stones can be tested after 13 throwing.
Reprinted statement:This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/kittyjie/archive/2009/10/27/4732415.aspx