题解 | #跳台阶扩展问题#
跳台阶扩展问题
https://www.nowcoder.com/practice/953b74ca5c4d44bb91f39ac4ddea0fee
import sys n = int(input().strip()) dp = [0] * (n+2) dp[0] = 0 dp[1] = 1 dp[2] = 2 #dp[n] = dp[n-1] + dp[n-2] + ... + dp[2] + dp[1] + dp[0] for i in range(n+1): for j in range(n-1,1,-1): #j从n-1 到0 dp[i] += dp[j] print(dp[n])