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 253bddc

Browse files
Merge pull request youngyangyang04#2457 from tianci-zhang/master
添加0070.爬楼梯完全背包版本.md Python3代码
2 parents ceec07f + f926ac8 commit 253bddc

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

‎problems/0070.爬楼梯完全背包版本.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,21 @@ class climbStairs{
165165
```
166166

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

179+
if __name__ == '__main__':
180+
n,m = list(map(int,input().split(' ')))
181+
print(climbing_stairs(n,m))
182+
```
169183

170184

171185
### Go:

0 commit comments

Comments
(0)

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