当前位置:网站首页>力扣-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
边栏推荐
- Tensorflow uses keras to create neural networks
- 2022爱分析· 工业互联网厂商全景报告
- [web daily practice] eight color puzzle (float)
- GPU, CUDA,cuDNN三者的关系总结
- 积极参与中学机器人竞赛的意义
- 博客文章导航(实时更新)
- AcWing 1874. Moo encryption (enumeration, hash)
- Redis optimization series (II) redis master-slave principle and master-slave common configuration
- QT 64 bit static version display gif
- 简易投票系统数据库设计
猜你喜欢
全网最细的短网址系统设计与实战
少儿编程结构的改变之路
Nacos Basics (5): getting started with Nacos configuration
On lambda powertools typescript
云呐|如何管理好公司的固定资产,固定资产管理怎么做
Tensorflow使用keras创建神经网络的方法
解决由于找不到amd_ags_x64.dll,无法继续执行代码。重新安装程序可能会解决此问题,地平线(Forza Horizon 5)
论坛系统数据库设计
After the MySQL router is reinstalled, it reconnects to the cluster for boot - a problem that has been configured in this host before
MQ在laravel中简单使用
随机推荐
Summary of convolution layer and pooling layer
[web daily practice] eight color puzzle (float)
2022爱分析· 工业互联网厂商全景报告
RebbitMQ的初步了解
After the MySQL router is reinstalled, it reconnects to the cluster for boot - a problem that has been configured in this host before
MySQL Router重装后重新连接集群进行引导出现的——此主机中之前已配置过的问题
云呐|如何管理好公司的固定资产,固定资产管理怎么做
解析性能良好的机器人使用守则
Application of remote integrated monitoring system in power distribution room in 10kV prefabricated cabin project
Understanding of MQ
解析社交性机器人对基础科学的作用
让中小学生在快乐中学习的创客教育
Summary of QT semaphore unresolved errors
Write console script by laravel
Database design of forum system
PSCP 基本使用
[Web 每日一练] 八色拼图(float)
第四章 为IM 启用填充对象之为IM列存储启用ADO(IM 4.8)
laravel编写Console脚本
激活函数之sigmoid函数