两个蛋的问题困惑困惑、两个、问题

2023-09-11 03:06:21 作者:回不去的过去

二蛋的问题:

您给出2个鸡蛋。 您可以使用一个100层的建筑。 在鸡蛋可能很难或很脆弱意味着它可能会打破,如果放弃从一楼甚至可能没有打破,如果从100个floor.Both鸡蛋下降是一致的。 您需要找出一个100层高的大楼一个鸡蛋的最高楼层可以在不破坏被丢弃。 现在的问题是,有多少滴你需要做。你被允许打破鸡蛋2个在这个过程中

我相信这两个蛋的问题(上述)已被充分讨论。但是可能有人帮助我理解了为什么下面的解决方案是不是最优的。

I am sure the two egg problem ( mentioned above ) has been discussed sufficiently. However could someone help me understand why the following solution is not optimal.

比方说,我用一个段,扫描算法与段大小取值。 因此,

Let's say I use a segment and scan algorithm with the segment size s. So,

d ( 100 / s   + (s-1) ) = 0    [ this should give the minima,  I need '(s-1)' scans per segment and there are '100/s' segments]
-
ds

=> -100 / s^2 + 1 = 0
=> s^2 = 100
=> s = 10

所以根据这一点,我需要至少19滴。但最佳的解决方案可以与14滴做到这一点。

So according to this I need at most 19 drops. But the optimal solution can do this with 14 drops.

那么,这就是问题所在?

So where lies the problem?

推荐答案

您好像假设相同大小的段。为最佳的解决方案,如果第一区段是大小为N,那么第二具有的大小为N-1,依此类推(因为当你开始测试第二段,你已经下降的蛋一次用于第一段)。

You seem to be assuming equal-sized segments. For an optimal solution, if the first segment is of size N, then the second has to be of size N-1, and so on (because when you start testing the second segment, you've already dropped the egg once for the first segment).

 
精彩推荐
图片推荐