当前位置:网站首页>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)
- STM32 standard firmware library function name memory (II)
- Fabric.js 手动加粗文本iText
- 1. Editing weapon VIM
- Simple verification code generator for 51 single chip microcomputer experiment
- The use of TestNG, the testing framework (II): the use of TestNG XML
- 复用和分用
- 广州市应急管理局发布7月高温高湿化工安全提醒
- 【无标题】LeetCode 2321. 拼接数组的最大分数
- Fabric. JS free drawing ellipse
猜你喜欢

天猫商品详情接口(APP,H5端)

Quick analysis: easy to share the Internet

Fabric. JS free draw circle

LeetCode - 搜索二维矩阵

The use of TestNG, the testing framework (II): the use of TestNG XML

Fabric. JS upper dash, middle dash (strikethrough), underline

mathML转latex

LeetCode 209. 长度最小的子数组

一张图彻底掌握prototype、__proto__、constructor之前的关系(JS原型、原型链)

Fabric. Usage of JS eraser (including recovery function)
随机推荐
Advanced C language (learn malloc & calloc & realloc & free in simple dynamic memory management)
Understanding of mongodb
Fabric. Keep the original level when JS element is selected
Some Chinese character codes in the user privacy agreement are not standardized, which leads to the display of garbled codes on the web page. It needs to be found and handled uniformly
Available solution development oral arithmetic training machine / math treasure / children's oral arithmetic treasure / intelligent math treasure LCD LCD driver ic-vk1622 (lqfp64 package), original te
Full of knowledge points, how to use JMeter to generate encrypted data and write it to the database? Don't collect it quickly
LeetCode_字符串_简单_412.Fizz Buzz
NLA natural language analysis realizes zero threshold of data analysis
Xilinx Vivado set *. svh as SystemVerilog Header
uniapp自动化测试学习
NLA natural language analysis makes data analysis more intelligent
Tujia muniao meituan has a discount match in summer. Will it be fragrant if the threshold is low?
大顶堆、小顶堆与堆排序
Delete element (with transition animation)
C# richTextBox控制显示最大行数
[development environment] install the visual studio community 2013 development environment (download the installation package of visual studio community 2013 with update 5 version)
OpenCV调用USB摄像头的点滴
buuctf-pwn write-ups (7)
Uniapp automated test learning
C语言习题---(数组)