题解 | #统计每个月兔子的总数#

统计每个月兔子的总数

http://www.nowcoder.com/practice/1221ec77125d4370833fd3ad5ba72395

#!/usr/sbin/python
# -*- coding: utf-8 -*-
import math
while True:
    try:
        int_mouth = int(input())    # 输入int型标识mouth第几个月
        mouth_1 = 1
        mouth_2 = 1
        result_num_all = []
        i = 1
        while i < int_mouth:
            result_num_all.append(mouth_2)
            mouth_1, mouth_2 = mouth_2, mouth_1 + mouth_2
            i += 1
            '''
            第1个月,1只
            第2个月,1只
            第3个月,2只1+1
            第4个月,3只2+1
            第5个月,5只3+2
            第6个月,8只4+3+1
            '''     # 算法
        # 输出兔子总数int型
        print(result_num_all[-1])
    except:
        break

全部评论

相关推荐

darius_:我试了简历上有微服务和没微服务主动要简历的外包的比例都不一样,微服务稍微看看还是要写上去,人人都写你不写会被pass
点赞 评论 收藏
分享
09-29 00:03
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务