当前位置:网站首页>LeetCode 2320. Count the number of ways to place the house
LeetCode 2320. Count the number of ways to place the house
2022-07-02 14:53:00 【HumbleFool】
LeetCode 2320. Count the number of ways to place the house 
const int mod = 1e9 + 7;
class Solution {
public:
int countHousePlacements(int n) {
vector<vector<int>> f(n + 1, vector<int>(2, 0));
// State machine model :f[i][1] On behalf of i One and with 0 End with 1 ending
f[1][0] = f[1][1] = 1;
for(int i = 2 ; i <= n; i ++)
{
f[i][1] = f[i - 1][0] % mod;
f[i][0] = (f[i - 1][0] + f[i - 1][1]) % mod;
}
long long t = 0LL + f[n][1] + f[n][0];
return t * t % mod;
}
};
边栏推荐
- Fabric.js 自由绘制圆形
- 用户隐私协议有些汉字编码不规范导致网页显示乱码,需要统一找出来处理一下
- info [email protected] : The platform “win32“ is incompatible with this module.
- Pychart connects to the remote server
- jmeter脚本参数化
- Bit by bit of OpenCV calling USB camera
- Advanced C language (learn malloc & calloc & realloc & free in simple dynamic memory management)
- Li Chuang EDA learning notes 15: draw border or import border (DXF file)
- 富文本编辑器添加矢量公式(MathType for TinyMCE ,可视化添加)
- Tujia muniao meituan has a discount match in summer. Will it be fragrant if the threshold is low?
猜你喜欢

Quick analysis: easy to share the Internet

jmeter脚本参数化

Design and implementation of car query system based on php+mysql

Li Chuang EDA learning notes 15: draw border or import border (DXF file)

buuctf-pwn write-ups (7)

PHP linked list creation and traversal

There is no solution to the decryption error of the remote user 'sa' and the service master password mapped from the remote server 'to the local user' (null) /sa '

【NOI模拟赛】刮痧(动态规划)

Add vector formula in rich text editor (MathType for TinyMCE, visual addition)

mathjax 入门(web显示数学公式,矢量的)
随机推荐
Xilinx Vivado set *.svh as SystemVerilog Header
Why can't browsers read JSX?
Fabric.js 动态设置字号大小
Fabric.js 自由绘制圆形
天猫商品详情接口(APP,H5端)
字符串匹配问题
Stm32-dac Experiment & high frequency DAC output test
报错:npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
LeetCode_滑动窗口_中等_395.至少有 K 个重复字符的最长子串
Fatal: unsafe repository is owned by someone else
mathjax 入门(web显示数学公式,矢量的)
大顶堆、小顶堆与堆排序
NLA natural language analysis makes data analysis more intelligent
LeetCode_字符串_简单_412.Fizz Buzz
关于网页中的文本选择以及统计选中文本长度
Threejs controller cube space basic controller + inertia control + flight control
2、const 型指针
Design and implementation of car query system based on php+mysql
Li Chuang EDA learning notes 15: draw border or import border (DXF file)
2. Const pointer