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

统计每个月兔子的总数

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

import sys
table1 = {'canout':0,'cannot':[[1,1]]}

for line in sys.stdin:
    a = int(line.strip())
    for i in range(1,a+1):
        tamp = []
        for j in table1['cannot']:
            if i - j[1] == 2:
                table1['canout'] += j[0]
                table1['cannot'].remove(j)
                table1['cannot'].append([table1['canout'],i])
                break
        else:
            if table1['canout'] != 0:
                table1['cannot'].append([table1['canout'],i])
re = table1['canout'] + sum([i[0] for i in table1['cannot']])
print(re)

全部评论

相关推荐

不愿透露姓名的神秘牛友
06-20 20:30
工作没了,落户没了,什么都没了
梦想是成为七海千秋:是因为什么原因呀,如果是因为导师恶意卡你就和他爆了
点赞 评论 收藏
分享
05-05 21:45
已编辑
广州大学 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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