problem

solution:

  1. class Solution {
  2. public:
  3. int tribonacci(int n) {
  4. if(n==) return ;
  5. if(n== || n==) return ;
  6. int t0 = , t1 = , t2 = , t3 = ;
  7. for(int i=; i<=n; i++)
  8. {
  9. t3 = t0+t1+t2;
  10. t0 = t1;
  11. t1 = t2;
  12. t2 = t3;
  13. }
  14. return t3;
  15. }
  16. };
 
 
参考

【Leetcode_easy】1137. N-th Tribonacci Number的更多相关文章

  1. 【BZOJ4922】[Lydsy六月月赛]Karp-de-Chant Number 贪心+动态规划

    [BZOJ4922][Lydsy六月月赛]Karp-de-Chant Number Description 卡常数被称为计算机算法竞赛之中最神奇的一类数字,主要特点集中于令人捉摸不透,有时候会让水平很 ...

  2. 【LeetCode】287. Find the Duplicate Number

    Difficulty:medium  More:[目录]LeetCode Java实现 Description Given an array nums containing n + 1 integer ...

  3. 【LeetCode】1150. Check If a Number Is Majority Element in a Sorted Array 解题报告(C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 字典 二分查找 日期 题目地址:https://lee ...

  4. 【bzoj4922】[Lydsy六月月赛]Karp-de-Chant Number 贪心+背包dp

    题目描述 给出 $n$ 个括号序列,从中选出任意个并将它们按照任意顺序连接起来,求以这种方式得到匹配括号序列的最大长度. 输入 第一行包含一个正整数n(1<=n<=300),表示括号序列的 ...

  5. 【51NOD-0】1137 矩阵乘法

    [算法]简单数学 [题解] 对于A*B=C C中第i行第j列的数字由A中第i行和B中的j列的数字各自相乘后相加得到. 所以两个矩阵能相乘要求A的列数等于B的行数,复杂度为O(n3). #include ...

  6. 【leetcode】1137. N-th Tribonacci Number

    题目如下: The Tribonacci sequence Tn is defined as follows: T0 = 0, T1 = 1, T2 = 1, and Tn+3 = Tn + Tn+1 ...

  7. 【LeetCode】1137. N-th Tribonacci Number 解题报告(C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 动态规划 日期 题目地址:https://leetc ...

  8. 【Leetcode_easy】933. Number of Recent Calls

    problem 933. Number of Recent Calls 参考 1. Leetcode_easy_933. Number of Recent Calls; 完

  9. 【Leetcode_easy】1128. Number of Equivalent Domino Pairs

    problem 1128. Number of Equivalent Domino Pairs solution1: 不明白为什么每个元素都要加上count: class Solution { pub ...

随机推荐

  1. uic

    uic user interface complieruic mainwindow.ui >> ui_mainwidow.h

  2. qt截图grapWindow,操作系统剪切版QClipBoard实现进程间通信

    QPixmap::grapWindow(winID) 存放一个图片QDesktopWidget 获得当前程序所在窗口id pid每个窗口有winID() // 3pixmap scaled 比例缩放 ...

  3. 洛谷 P1056 排座椅 题解

    P1056 排座椅 题目描述 上课的时候总会有一些同学和前后左右的人交头接耳,这是令小学班主任十分头疼的一件事情.不过,班主任小雪发现了一些有趣的现象,当同学们的座次确定下来之后,只有有限的 \(D\ ...

  4. 想学习找不到好的博客?看这里>>

    想学习找不到好的博客?看这里>> (ps:内容 + 作者) 基础数论知识整理--gyh 进阶数论知识整理--又是gyh 关于SPFA--lyj(终于不是gyh) 证明二次探测定理-Line ...

  5. C语言实现多线程排序

    #include <stdio.h> #include <pthread.h> #include <stdlib.h> #include <string.h& ...

  6. 比较实用的Java工具类

    一. org.apache.commons.io.IOUtils closeQuietly:关闭一个IO流.socket.或者selector且不抛出异常,通常放在finally块 toString: ...

  7. hbase错误记录部分总结

    错误1:org.apache.zookeeper.KeeperException$SessionExpiredException: KeeperErrorCode = Session expired ...

  8. 怎么将输出的字符串换行输出,replace

    var getAllData="我是第一行,我是第二行,我是第三行" var toBreak=getAllData.replace(/,/g, "\n") // ...

  9. 【Vue.js游戏机实战】- Vue.js实现大转盘抽奖总结

    大家好!先上图看看本次案例的整体效果. 实现思路: Vue component实现大转盘组件,可以嵌套到任意要使用的页面. css3 transform控制大转盘抽奖过程的动画效果. 抽奖组件内使用钩 ...

  10. java.io.FileNotFoundException: D:\e (拒绝访问。)

    这是因为访问的文件地址是文件夹而不是,具体的文件,把路径改为具体的文件就可以了. 参考文章:https://blog.csdn.net/w405722907/article/details/78610 ...