分析;
跟上道题一样,只不过变成了前三个状态的和
直接给出代码,一次性过
代码:
1 class Solution(object): 2 def tribonacci(self, n): 3 """ 4 :type n: int 5 :rtype: int 6 """ 7 if n==0: 8 return 0 9 if n<3: 10 return 1 11 f=[0 for i in range(n+1)] 12 f[0]=0 13 f[1]=1 14 f[2]=1 15 for i in range(3,n+1): 16 f[i]=f[i-1]+f[i-2]+f[i-3] 17 return f[-1]
标签:契数,int,代码,个泰波,1137,tribonacci From: https://www.cnblogs.com/ooooopppp/p/17357187.html