题解 | #统计每个月兔子的总数#
统计每个月兔子的总数
https://www.nowcoder.com/practice/1221ec77125d4370833fd3ad5ba72395
n = int(input()) dp =[] for i in range(0,n): if i < 2: total = 1 dp.append(total) else: total = dp[i-1] + dp[i-2] dp.append(total) print(dp[-1])
统计每个月兔子的总数
https://www.nowcoder.com/practice/1221ec77125d4370833fd3ad5ba72395
n = int(input()) dp =[] for i in range(0,n): if i < 2: total = 1 dp.append(total) else: total = dp[i-1] + dp[i-2] dp.append(total) print(dp[-1])
相关推荐