mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-05 15:31:43 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给你 <strong>2 枚相同 </strong>的鸡蛋,和一栋从第 <code>1</code> 层到第 <code>n</code> 层共有 <code>n</code> 层楼的建筑。</p>\n\n<p>已知存在楼层 <code>f</code> ,满足 <code>0 <= f <= n</code> ,任何从 <strong>高于 </strong><code>f</code> 的楼层落下的鸡蛋都<strong> 会碎 </strong>,从 <strong><code>f</code> 楼层或比它低 </strong>的楼层落下的鸡蛋都 <strong>不会碎 </strong>。</p>\n\n<p>每次操作,你可以取一枚<strong> 没有碎</strong> 的鸡蛋并把它从任一楼层 <code>x</code> 扔下(满足 <code>1 <= x <= n</code>)。如果鸡蛋碎了,你就不能再次使用它。如果某枚鸡蛋扔下后没有摔碎,则可以在之后的操作中<strong> 重复使用 </strong>这枚鸡蛋。</p>\n\n<p>请你计算并返回要确定 <code>f</code> <strong>确切的值 </strong>的 <strong>最小操作次数</strong> 是多少?</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<strong>输入:</strong>n = 2\n<strong>输出:</strong>2\n<strong>解释:</strong>我们可以将第一枚鸡蛋从 1 楼扔下,然后将第二枚从 2 楼扔下。\n如果第一枚鸡蛋碎了,可知 f = 0;\n如果第二枚鸡蛋碎了,但第一枚没碎,可知 f = 1;\n否则,当两个鸡蛋都没碎时,可知 f = 2。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<strong>输入:</strong>n = 100\n<strong>输出:</strong>14\n<strong>解释:\n</strong>一种最优的策略是:\n- 将第一枚鸡蛋从 9 楼扔下。如果碎了,那么 f 在 0 和 8 之间。将第二枚从 1 楼扔下,然后每扔一次上一层楼,在 8 次内找到 f 。总操作次数 = 1 + 8 = 9 。\n- 如果第一枚鸡蛋没有碎,那么再把第一枚鸡蛋从 22 层扔下。如果碎了,那么 f 在 9 和 21 之间。将第二枚鸡蛋从 10 楼扔下,然后每扔一次上一层楼,在 12 次内找到 f 。总操作次数 = 2 + 12 = 14 。\n- 如果第一枚鸡蛋没有再次碎掉,则按照类似的方法从 34, 45, 55, 64, 72, 79, 85, 90, 94, 97, 99 和 100 楼分别扔下第一枚鸡蛋。\n不管结果如何,最多需要扔 14 次来确定 f 。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= n <= 1000</code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 43,
|
||||
"likes": 49,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -143,7 +143,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"4K\", \"totalSubmission\": \"5.8K\", \"totalAcceptedRaw\": 3970, \"totalSubmissionRaw\": 5782, \"acRate\": \"68.7%\"}",
|
||||
"stats": "{\"totalAccepted\": \"4.4K\", \"totalSubmission\": \"6.4K\", \"totalAcceptedRaw\": 4432, \"totalSubmissionRaw\": 6421, \"acRate\": \"69.0%\"}",
|
||||
"hints": [
|
||||
"Is it really optimal to always drop the egg on the middle floor for each move?",
|
||||
"Can we create states based on the number of unbroken eggs and floors to build our solution?"
|
||||
|
Reference in New Issue
Block a user