当前位置:网站首页>力扣-1137.第N个泰波那契数
力扣-1137.第N个泰波那契数
2022-04-23 11:38:00 【Node_Su】

class Solution(object):
def tribonacci(self, n):
"""
:type n: int
:rtype: int
"""
if n == 1 or n == 0:
return n
if n == 2:
return 1
dp_1 = 1
dp_2 = 1
dp_3 = 0
for i in range(3, n + 1):
res = dp_1 + dp_2 + dp_3
dp_3 = dp_2
dp_2 = dp_1
dp_1 = res
i = i + 1
return dp_1
if __name__ == '__main__':
n = 25
Sol = Solution()
res = Solution.tribonacci(Sol, n)
print(res)
版权声明
本文为[Node_Su]所创,转载请带上原文链接,感谢
https://blog.csdn.net/Node_Su/article/details/124360637
边栏推荐
- qt5.8 64 位静态库中想使用sqlite但静态库没有编译支持库的方法
- 配电房远程综合监控系统在10kV预制舱项目中的应用
- 激活函数之阶跃函数
- 用curl库压缩成发送字符串为utf8并用curl库发送
- Share two practical shell scripts
- MIT: label every pixel in the world with unsupervised! Humans: no more 800 hours for an hour of video
- Résumé de la relation entre GPU, cuda et cudnn
- 获取钉钉考勤机打卡记录
- 解决由于找不到amd_ags_x64.dll,无法继续执行代码。重新安装程序可能会解决此问题,地平线(Forza Horizon 5)
- Overall plan management mode in maker Education
猜你喜欢
随机推荐
积极参与中学机器人竞赛的意义
Overall plan management mode in maker Education
探究机器人教育的器材与教学
Design and practice of the smallest short website system in the whole network
简易投票系统数据库设计
项目实训-火爆辣椒
How does QT turn qwigdet into qdialog
Understanding of MQ
数据库如何填充IM表达式(IM 5.4)
解析性能良好的机器人使用守则
激活函数之relu函数
AcWing 1874. Moo encryption (enumeration, hash)
分享两个实用的shell脚本
Tensorflow uses keras to create neural networks
MQ在laravel中简单使用
ES6学习笔记二
讯飞2021年营收183亿:同比增41% 净利为15.56亿
系统编程之高级文件IO(十三)——IO多路复用-select
MySQL 的主从复制配置
博客文章导航(实时更新)








