题解 | #统计每个月兔子的总数#
统计每个月兔子的总数
https://www.nowcoder.com/practice/1221ec77125d4370833fd3ad5ba72395
def rabbit(n: int):
old = [0, 0, 1, 1]
new = [1, 1, 1, 2]
res = [1, 1, 2, 3]
if n > 4:
for i in range(4, n):
old.append(old[i - 2] + old[i - 1])
new.append(new[i - 1] + old[i] - old[i - 2])
res.append(old[i] + new[i])
return res[n - 1]
print(rabbit(int(input())))
