【Leetcode_easy】1137. N-th Tribonacci Number
problem
solution:
class Solution {
public:
int tribonacci(int n) {
if(n==) return ;
if(n== || n==) return ;
int t0 = , t1 = , t2 = , t3 = ;
for(int i=; i<=n; i++)
{
t3 = t0+t1+t2;
t0 = t1;
t1 = t2;
t2 = t3;
}
return t3;
}
};
【Leetcode_easy】1137. N-th Tribonacci Number的更多相关文章
- 【BZOJ4922】[Lydsy六月月赛]Karp-de-Chant Number 贪心+动态规划
[BZOJ4922][Lydsy六月月赛]Karp-de-Chant Number Description 卡常数被称为计算机算法竞赛之中最神奇的一类数字,主要特点集中于令人捉摸不透,有时候会让水平很 ...
- 【LeetCode】287. Find the Duplicate Number
Difficulty:medium More:[目录]LeetCode Java实现 Description Given an array nums containing n + 1 integer ...
- 【LeetCode】1150. Check If a Number Is Majority Element in a Sorted Array 解题报告(C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 字典 二分查找 日期 题目地址:https://lee ...
- 【bzoj4922】[Lydsy六月月赛]Karp-de-Chant Number 贪心+背包dp
题目描述 给出 $n$ 个括号序列,从中选出任意个并将它们按照任意顺序连接起来,求以这种方式得到匹配括号序列的最大长度. 输入 第一行包含一个正整数n(1<=n<=300),表示括号序列的 ...
- 【51NOD-0】1137 矩阵乘法
[算法]简单数学 [题解] 对于A*B=C C中第i行第j列的数字由A中第i行和B中的j列的数字各自相乘后相加得到. 所以两个矩阵能相乘要求A的列数等于B的行数,复杂度为O(n3). #include ...
- 【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 ...
- 【LeetCode】1137. N-th Tribonacci Number 解题报告(C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 动态规划 日期 题目地址:https://leetc ...
- 【Leetcode_easy】933. Number of Recent Calls
problem 933. Number of Recent Calls 参考 1. Leetcode_easy_933. Number of Recent Calls; 完
- 【Leetcode_easy】1128. Number of Equivalent Domino Pairs
problem 1128. Number of Equivalent Domino Pairs solution1: 不明白为什么每个元素都要加上count: class Solution { pub ...
随机推荐
- asp.net+ueditor word粘贴上传
最近公司做项目需要实现一个功能,在网页富文本编辑器中实现粘贴Word图文的功能. 我们在网站中使用的Web编辑器比较多,都是根据用户需求来选择的.目前还没有固定哪一个编辑器 有时候用的是UEditor ...
- [分享]Hidden Start - NTWind Software
https://bbs.pediy.com/thread-229336.htm [[other]] [分享]Hidden Start - NTWind Software 2018-6-29 09: ...
- SPOJ简介。
今天一如既往地在luogu刷题,发现了一个新OJ,就去网上查资料.得到了下面这些. 以下转载自这里 SPOJ是波兰最为出色的Online Judge之一,界面和谐,题目类型也非常丰富,适合有一定基础的 ...
- PCI BAR设置过程[转]
最近因为工作需要用到pci设备的BAR内容,之前看了没深刻印象,这里整理一下. PCI设备有很好的可配置型和易操作性,这很大方面要归功于其地址空间的可动态分配的特性.而动态分配地址空间就是依赖于BAR ...
- Android精通教程-Android入门简介
前言 大家好,我是 Vic,今天给大家带来Android精通教程-Android入门简介的概述,希望你们喜欢 每日一句 If life were predictable it would cease ...
- UOJ226. 【UR #15】奥林匹克环城马拉松 [组合数学,图论]
UOJ 思路 我们知道关于有向图欧拉回路计数有一个结论:在每个点入度等于出度的时候,答案就是 \[ t_w(G)\prod (deg_i-1)! \] 其中\(t_w(G)\)是以某个点为根的树形图个 ...
- Dart 日期时间 DateTime
1.获取当前时间 var now = new DateTime.now(); print(now); // 2019-06-20 16:59:05.560543 2.设置时间 var d =new D ...
- response.getWriter().println和@ResponseBody的比较及同时使用(用于回调函数)
@RequestMapping(value = "/test", method = { RequestMethod.GET, RequestMethod.POST }) @Resp ...
- VS2010专业版和旗舰版(中文版)下载
本文转载自https://blog.csdn.net/chy2z/article/details/80080399 注意: 中文版为iso镜像文件,使用 Daemon Tools 虚拟光驱软件载入进行 ...
- 约翰·麦斯威尔 | John C. Maxwell | A leader is one who knows the way, goes the way, and shows the way.
约翰·麦斯威尔_百度百科https://baike.baidu.com/item/%E7%BA%A6%E7%BF%B0%C2%B7%E9%BA%A6%E6%96%AF%E5%A8%81%E5%B0%9 ...