leetcode790 Domino and Tromino Tiling
思路:
dp。没有像discuss中的那样优化递推式。
实现:
class Solution
{
public:
const int MOD = 1e9 + ;
int numTilings(int N)
{
vector<vector<int>> dp(N + , vector<int>(, ));
dp[][] = ;
dp[][] = dp[][] = dp[][] = ;
for (int i = ; i <= N; i++)
{
dp[i][] = (((dp[i - ][] + dp[i - ][]) % MOD + dp[i - ][]) % MOD + dp[i - ][]) % MOD;
dp[i][] = (dp[i - ][] + dp[i - ][]) % MOD;
dp[i][] = (dp[i - ][] + dp[i - ][]) % MOD;
}
return dp[N][] % MOD;
}
};
leetcode790 Domino and Tromino Tiling的更多相关文章
- [Swift]LeetCode790. 多米诺和托米诺平铺 | Domino and Tromino Tiling
We have two types of tiles: a 2x1 domino shape, and an "L" tromino shape. These shapes may ...
- [LeetCode] Domino and Tromino Tiling 多米诺和三格骨牌
We have two types of tiles: a 2x1 domino shape, and an "L" tromino shape. These shapes may ...
- 790. Domino and Tromino Tiling
We have two types of tiles: a 2x1 domino shape, and an "L" tromino shape. These shapes may ...
- 73th LeetCode Weekly Contest Domino and Tromino Tiling
We have two types of tiles: a 2x1 domino shape, and an "L" tromino shape. These shapes may ...
- leetcode 790. Domino and Tromino Tiling
We have two types of tiles: a 2x1 domino shape, and an "L" tromino shape. These shapes may ...
- 【LeetCode】790. Domino and Tromino Tiling 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/domino-a ...
- 动态规划-填格子问题 Domino and Tromino Tiling
2018-09-01 22:38:19 问题描述: 问题求解: 本题如果是第一看到,应该还是非常棘手的,基本没有什么思路. 不妨先从一种简化的版本来考虑.如果仅有一种砖块,那么,填充的方式如下.
- [LeetCode] Minimum Window Subsequence 最小窗口序列
Given strings S and T, find the minimum (contiguous) substring W of S, so that T is a subsequence of ...
- Swift LeetCode 目录 | Catalog
请点击页面左上角 -> Fork me on Github 或直接访问本项目Github地址:LeetCode Solution by Swift 说明:题目中含有$符号则为付费题目. 如 ...
随机推荐
- Receiver type ‘X’ for instance message is a forward declaration
这往往是引用的问题. ARC要求完整的前向引用,也就是说在MRC时代可能仅仅须要在.h中申明@class就能够,可是在ARC中假设调用某个子类中未覆盖的父类中的方法的话.必须对父类.h引用,否则无法编 ...
- nhibernate的关系
用nhibernate,觉得比较难把握的是其中表间的关系. 我用的是Fluently Nhibernate,直接用代码,而不是XML来书写代码与数据表的映射.其中表间关系有3种: 1.Referenc ...
- 2016/3/1 淘宝 腾讯 网易 css初始化代码 以及最基础的初始化
淘宝官网(http://www.taobao.com/)样式初始化 body, h1, h2, h3, h4, h5, h6, hr, p, blockquote, dl, dt, dd, ul, o ...
- 3.myeclipse 8.5 m1 注册码
为了能在eclipse 中方便的使用uml,尝试了多次安装各种uml插件未果,myeclipse 自带uml插件,但是要注册啊,要破解啊!!! user:baiduzhidaopassword:oLR ...
- qrcode.react和jquery.qrcode生成二维码
qrcode.react 1.安装 npm install qrcode.react 2.用法(这里用的ant design) import React from 'react'; import QR ...
- SoapUI中Code多行显示设置
你们的SoapUI 有设置下面的选项吗? Before adding your project, we recommend that you enable the following ReadyAPI ...
- Mac Mysql [ERR] 2006 - MySQL server has gone away
Mac mysql 安装后,导入sql数据,出现这个错误: 处理方式,是因为sql文件太大,需要修改mysql的配置.如果没有my.cnf就自己建一个. cd /etc sudo vim my.cnf ...
- jQuery简单纯文字提示条
如何制作jQuery简单纯文字提示条,先介绍提示条(tooltip)的意思是用户鼠标悬停经过事件发生提示title.它们已经呈现在大多数浏览器中,当你可以提供一个链接或图片的title属性,就是用户将 ...
- gfnormal 域名 是阿里云的高防IP
最近DGA检出了一堆阿里高防的域名,例如:u3mbyv2siyaw2tnm.gfnormal09aq.com,然后专门查找了下相关文档. 例如 8264.com 这个网站启用了aliyun的高防DDo ...
- c++爬虫子
Larbin是一个用C++开发的开源网络爬虫,有一定的定制选项和较高的网页抓取速度. 下图表示了一般爬虫抓取网页的基本过程. 抓取以/Larbin.conf中的startUrl做为种子URLs开始. ...