Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
tiechui1994 committed Jun 23, 2024
1 parent d67bf62 commit de8cebe
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions algorithm/dp/dp.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ dp[i] 表示源串的前i个字符可以满足分割, 那么 dp[ j ] 满足分
```
01背包问题:
dp[i][w] 表示选择 nums[0:i] 个元素, 重量不超过 w 的最大价值:
dp[i][w] 表示选择 w[0:i] 个元素, 重量不超过 w 的最大价值:
dp[i][w] = max(dp[i-1][w - nums[i]]+nums[i], dp[i-1][w])
dp[i][w] = max(dp[i-1][w - w[i] + p[i], dp[i-1][w])
for i in [1..N]:
for w in [1..W]:
Expand All @@ -183,13 +183,13 @@ return dp[N][W]
```
完全背包问题:
dp[i][w] 表示选择 nums[0:i] 个元素, 重量不超过 w 的最大价值:
dp[i][w] 表示选择 w[0:i] 个元素, 重量不超过 w 的最大价值:
dp[i][w] = max(dp[i-1][w - k*nums[i]] + k*nums[i]) 0 <= k <= +OO
dp[i][w] = max(dp[i-1][w - k*w[i]] + k*p[i]) 0 <= k <= +OO
||、
dp[i][w] = max(dp[i-1][w - nums[i]] + nums[i])
dp[i][w] = max(dp[i-1][w - w[i] + p[i], dp[i-1][w])
for i in [1..N]:
for w in [1..W]:
Expand Down

0 comments on commit de8cebe

Please sign in to comment.