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

[pull] master from youngyangyang04:master #426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
pull merged 2 commits into AlgorithmAndLeetCode:master from youngyangyang04:master
Mar 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
添加0070.爬楼梯完全背包版本.md Python3代码
添加0070.爬楼梯完全背包版本.md Python3代码
  • Loading branch information
tianci-zhang authored Feb 29, 2024
commit f926ac8f390f63236426ca29f2bfd63ad98685c9
14 changes: 14 additions & 0 deletions problems/0070.爬楼梯完全背包版本.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,21 @@ class climbStairs{
```

### Python3:
```python3
def climbing_stairs(n,m):
dp = [0]*(n+1) # 背包总容量
dp[0] = 1
# 排列题,注意循环顺序,背包在外物品在内
for j in range(1,n+1):
for i in range(1,m+1):
if j>=i:
dp[j] += dp[j-i] # 这里i就是重量而非index
return dp[n]

if __name__ == '__main__':
n,m = list(map(int,input().split(' ')))
print(climbing_stairs(n,m))
```


### Go:
Expand Down

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