当前位置:网站首页>LeetCode 2320. 统计放置房子的方式数
LeetCode 2320. 统计放置房子的方式数
2022-07-02 11:26:00 【HumbleFool】
const int mod = 1e9 + 7;
class Solution {
public:
int countHousePlacements(int n) {
vector<vector<int>> f(n + 1, vector<int>(2, 0));
// 状态机模型:f[i][1] 代表前i个且以0结尾或以1结尾
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;
}
};
边栏推荐
- 3. Function pointers and pointer functions
- Ad20 cannot select the solution of component packaging in PCB editor
- kityformula-editor 配置字号和间距
- STM32 standard firmware library function name (I)
- 【apipost】使用教程
- Implement a server with multi process concurrency
- socket(套接字)与socket地址
- 4. Array pointer and pointer array
- Factal: Unsafe repository is owned by someone else Solution
- 3、函数指针和指针函数
猜你喜欢
[email protected]: The platform “win32“ is incompatible with this module."/>info [email protected]: The platform “win32“ is incompatible with this module.

使用mathtype编辑公式,复制粘贴时设置成仅包含mathjax语法的公式

Fabric.js 上划线、中划线(删除线)、下划线

《可供方案开发》口算训练机/数学宝/儿童口算宝/智能数学宝 LCD液晶显示驱动IC-VK1622(LQFP64封装),原厂技术支持

实现一个多进程并发的服务器

What is erdma? Popular science cartoon illustration

Implement a server with multi process concurrency

Quick analysis: easy to share the Internet

Reuse and distribution

The most complete analysis of Flink frame window function
随机推荐
Makefile 分隔文件名与后缀
[Space & single cellomics] phase 1: single cell binding space transcriptome research PDAC tumor microenvironment
tmall. product. schema. Get (product information acquisition schema acquisition), Taobao store upload commodity API interface, Taobao commodity publishing interface, Taobao commodity upload API interf
Advanced C language (learn malloc & calloc & realloc & free in simple dynamic memory management)
数据库连接池和数据源
MathML to latex
复用和分用
taobao. trade. memo. Add (add remarks to a transaction) interface, Taobao store flag insertion interface, Taobao order flag insertion API interface, oauth2.0 interface
富文本编辑器添加矢量公式(MathType for TinyMCE ,可视化添加)
途家木鸟美团夏日折扣对垒,门槛低就一定香吗?
docker mysql
buuctf-pwn write-ups (7)
Tip: SQL Server blocked the state 'openrowset/opendatasource' of component 'ad hoc distributed queries'
Check password
threejs的控制器 立方体空间 基本控制器+惯性控制+飞行控制
2、const 型指针
Advanced usage of C language -- function pointer: callback function; Conversion table
The use of TestNG, the testing framework (II): the use of TestNG XML
4. Array pointer and pointer array
Use of freemaker
