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 328ffcc

Browse files
Merge pull request #446 from tlovem/patch-1
Update 背包理论基础01背包-1.md
2 parents ffbe980 + 0aead41 commit 328ffcc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

‎problems/背包理论基础01背包-1.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ leetcode上没有纯01背包的问题,都是01背包应用方面的题目,
8282

8383
那么可以有两个方向推出来dp[i][j],
8484

85-
* 由dp[i - 1][j]推出,即背包容量为j,里面不放物品i的最大价值,此时dp[i][j]就是dp[i - 1][j]
85+
* 由dp[i - 1][j]推出,即背包容量为j,里面不放物品i的最大价值,此时dp[i][j]就是dp[i - 1][j]。(其实就是当物品i的重量大于背包j的重量时,物品i无法放进背包中,所以被背包内的价值依然和前面相同。)
8686
* 由dp[i - 1][j - weight[i]]推出,dp[i - 1][j - weight[i]] 为背包容量为j - weight[i]的时候不放物品i的最大价值,那么dp[i - 1][j - weight[i]] + value[i] (物品i的价值),就是背包放物品i得到的最大价值
8787

8888
所以递归公式: dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - weight[i]] + value[i]);

0 commit comments

Comments
(0)

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