题解 | #斐波那契数列#
斐波那契数列
https://www.nowcoder.com/practice/ee5d403c1172487f8c7915b3c3d924c6
def shulie(n):
if n > 1:
dp = [0] *int(n)
dp[0] = 1
dp[1] = 1
for i in range(2, n):
dp[i] = dp[i-1] + dp[i-2]
return dp[n-1]
else:
return 1
while True:
try:
b = int(input())
dp = shulie(b)
print(dp)
except:
break
理解动态规划的推导公式
查看3道真题和解析