题解 | #统计每个月兔子的总数#
统计每个月兔子的总数
https://www.nowcoder.com/practice/1221ec77125d4370833fd3ad5ba72395
import sys #开始1只:特点,第三月生一只,第四月也1只,子子孙孙无穷 rabit_total = int(1) month_num = int(input()) rabit_0 = rabit_total rabit_1 = int(0) rabit_2 = int(0) #思路没过一个月,兔子的年龄都会流转一轮 #深究文字其实可以知道,流转一轮的时间不是三个月,而是两个月(第三个月) for i in range(1,month_num): #成年兔和一个月的兔子之和等于0月新生兔 rabit_2 = rabit_1 + rabit_2 rabit_1 = rabit_0 rabit_0 = rabit_2 #流转结束,且循环计数是从1到n的,月历法说明第1月到第3月之间其实就两个月 rabit_total = rabit_0 + rabit_1 + rabit_2 print(rabit_total)