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 说明:题目中含有$符号则为付费题目. 如 ...
随机推荐
- android 怎样将主菜单图标改成按安装时间排序
1. 在 LauncherModel.java 中增加例如以下代码, 假设是KK Launcher3 ApplicationInfo要替换为AppInfo public static final Co ...
- iOS 浅谈MVC设计模式及Controllers之间的传值方式
1.简述你对MVC的理解? MVC是一种架构设计.它考虑了三种对象:Model(模型对象).View(试图对象).Controller(试图控制器) (1)模型:负责存储.定义.操作数据 (2)视图: ...
- 生成 hibernate 映射文件和实体类
创建web工程,使用Hibernate的时候,在工程里一个一个创建实体类太麻烦,浪费时间,现在教大家如何用MyEclipse自动生成Hibernate映射文件及实体类 方法/步骤 创建数据库,创建 ...
- 配置JDK环境变量配置及path和classpath的作用
1.环境变量配置 用鼠标右击“我的电脑”->属性->高级->环境变量 JAVA_HOME :D:\Program Files\Java\jdk1.6.0_12(JDK安装路径) Pa ...
- android ndk环境搭建,如果是mac,请先装mac make编译器(可以使用Xcode进行安装)
Android SDK:android-sdk-mac_86Android NDK: android-ndk-r4b-darwin-x86EclipseADTCDTANT搭建Android SDK开发 ...
- SQLite数据库框架--FMDB简单介绍
1.什么是FMDB FMDB是iOS平台的SQLite数据库框架 FMDB以OC的方式封装了SQLite的C语言API 2.FMDB的优点 使用起来更加面向对象,省去了很多麻烦.冗余的C语言代码 对比 ...
- Are you sure you want to continue connecting etc ssh ssh_config StrictHostKeyChecking no
Are you sure you want to continue connecting (yes/no) 每次ssh 进入一台新机器都会跳出如下的提示: The authenticity of ho ...
- UVa 1363 Joseph's Problem (数论)
题意:给定 n,k,求 while(i <=n) k % i的和. 析:很明显是一个数论题,写几个样例你会发现规律,假设 p = k / i.那么k mod i = k - p*i,如果 k ...
- Unity3d 应用系统分析
- 8. VIM 系列 - 利用 VIM 8.1 版本编译项目和GDB调试
目录 term 模式 termdebug 模式 VIM版本安装请参考: 0. VIM 系列 - 源码升级最新版本vim term 模式 输入:term 打开此模式,效果如下 这个模式有编辑文本窗口和s ...