当前位置:网站首页>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;
}
};
边栏推荐
- 大顶堆、小顶堆与堆排序
- 由粒子加速器产生的反中子形成的白洞
- Thoroughly master prototype__ proto__、 Relationship before constructor (JS prototype, prototype chain)
- PTA题库 ===>复数四则运算,一帮一,考试座位号(7-73)
- 记一次报错解决经历依赖重复
- STM32-DAC实验&高频DAC输出测试
- Threejs controller cube space basic controller + inertia control + flight control
- [QNX hypervisor 2.2 user manual]6.3 communication between guest and external
- STM32标准固件库函数名记忆(二)
- 天猫商品详情接口(APP,H5端)
猜你喜欢

Yyds dry goods inventory software encryption lock function

Actual combat sharing of shutter screen acquisition

Fabric.js 橡皮擦的用法(包含恢复功能)

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 '

mathML转latex
![[Space & single cellomics] phase 1: single cell binding space transcriptome research PDAC tumor microenvironment](/img/e1/c8e81570ab78de1e488a611c25ebb9.png)
[Space & single cellomics] phase 1: single cell binding space transcriptome research PDAC tumor microenvironment

Stm32-dac Experiment & high frequency DAC output test

Obsidian installs third-party plug-ins - unable to load plug-ins

Tip: SQL Server blocked the state 'openrowset/opendatasource' of component 'ad hoc distributed queries'
[email protected]: The platform “win32“ is incompatible with this module."/>info [email protected]: The platform “win32“ is incompatible with this module.
随机推荐
Fabric. Usage of JS eraser (including recovery function)
Edit the formula with MathType, and set it to include only mathjax syntax when copying and pasting
C#代码审计实战+前置知识
C# richTextBox控制显示最大行数
关于网页中的文本选择以及统计选中文本长度
taobao. logistics. dummy. Send (no logistics delivery processing) interface, Taobao store delivery API interface, Taobao order delivery interface, Taobao R2 interface, Taobao oau2.0 interface
C语言中的算术运算及相关练习题
实现一个多进程并发的服务器
Wechat applet uses towxml to display formula
检查密码
4、数组指针和指针数组
数据库连接池和数据源
Bit by bit of OpenCV calling USB camera
Fatal: unsafe repository is owned by someone else
MQ教程 | Exchange(交换机)
Slashgear shares 2021 life changing technology products, which are somewhat unexpected
删除元素(带过渡动画)
OpenCV调用USB摄像头的点滴
Thoroughly master prototype__ proto__、 Relationship before constructor (JS prototype, prototype chain)
华为面试题: 没有回文串