Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f0fd034

Browse files
Update Readme.md
1 parent 3b50e51 commit f0fd034

File tree

1 file changed

+1
-1
lines changed
  • Dynamic_Programming/1884.Egg-Drop-With-2-Eggs-and-N-Floors

1 file changed

+1
-1
lines changed

‎Dynamic_Programming/1884.Egg-Drop-With-2-Eggs-and-N-Floors/Readme.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
此题是```887.Super-Egg-Drop```的简化版本。
44

5-
对于i层楼,如果只有一个鸡蛋,我们需要测几次呢?显然只能一层一层,从第1层开始尝试,最多可能一直到到第i层都不碎(注意题目允许在最高层都不碎)。所以需要n次测试,我们记做```dp[i][1]=1```.
5+
对于i层楼,如果只有一个鸡蛋,我们需要测几次呢?显然只能一层一层,从第1层开始尝试,最多可能一直到到第i层都不碎(注意题目允许在最高层都不碎)。所以需要n次测试,我们记做```dp[i][1]=i```.
66

77
现在我们有两个鸡蛋。我们遍历第一个鸡蛋放在哪里。假设放在第j层,如果碎了,那么说明我们需要用剩下的一颗鸡蛋来确定极限层(恰好不破)在下方的j-1层的哪里,即dp[j-1][1]. 如果没有碎,说明极限层在第j层到第n层之间。此时我们可以把第j层看做相当于第0层(因为肯定不会破),所以我们需要的是在剩下的i-j层里面用两颗鸡蛋来确定极限层,即dp[i-j][2]. 考虑最坏情况,取```max{dp[j-1][1], dp[i-j][2]}```
88

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /