两枚鸡蛋的 100 层扔蛋问题
Two Eggs Dropping Puzzle
题目详情
你在一栋 100 层楼里,有两枚完全相同的玻璃鸡蛋。想找出从哪一层开始扔会碎的临界楼层 (即从 层扔不碎、从 层扔会碎)。
问:为了在最坏情况下保证找到 ,最少需要扔多少次?
You are in a 100-story building and have two identical glass eggs. You want to find the highest floor from which an egg can be dropped without breaking, which we'll call the "critical floor" . What is the minimum number of drops you need to guarantee finding in the worst-case scenario?
解析
两枚蛋的经典最优策略是用“递减步长”来平衡两种最坏情况:
第一次从第 层扔。
- 若碎了,则剩下一枚蛋,只能从 1 到 线性搜索,最多再扔 次,总共 次;
- 若不碎,则下一次从第 层扔;再不碎则加 ,依此类推。
要覆盖到 100 层,需要
最小满足者为 (因为 ,而 )。
因此最坏情况下最少需要 次。