当前位置:网站首页>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;
}
};
边栏推荐
- fatal: unsafe repository is owned by someone else 的解决方法
- Tip: SQL Server blocked the state 'openrowset/opendatasource' of component 'ad hoc distributed queries'
- Slashgear shares 2021 life changing technology products, which are somewhat unexpected
- Fabric.js 橡皮擦的用法(包含恢复功能)
- 《可供方案开发》口算训练机/数学宝/儿童口算宝/智能数学宝 LCD液晶显示驱动IC-VK1622(LQFP64封装),原厂技术支持
- STM32 standard firmware library function name memory (II)
- What is erdma? Popular science cartoon illustration
- taobao.trade.memo.add( 对一笔交易添加备注 )接口,淘宝店铺插旗接口,淘宝订单插旗API接口,oAuth2.0接口
- threejs的控制器 立方体空间 基本控制器+惯性控制+飞行控制
- Threejs controller cube space basic controller + inertia control + flight control
猜你喜欢
【apipost】使用教程
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 '
Implement a server with multi process concurrency
Fabric. JS free draw circle
It's no exaggeration to say that this is the most user-friendly basic tutorial of pytest I've ever seen
Quick analysis: easy to share the Internet
Error: NPM warn config global ` --global`, `--local` are deprecated Use `--location=global` instead.
Fabric.js 自由绘制圆形
< schéma de développement de la machine d'exercice oral > machine d'exercice oral / trésor d'exercice oral / trésor de mathématiques pour enfants / lecteur LCD de calculatrice pour enfants IC - vk1621
uniapp自动化测试学习
随机推荐
The evolution process of the correct implementation principle of redis distributed lock and the summary of redison's actual combat
Fabric. JS free drawing ellipse
卷积神经网络(入门)
YoloV6训练:训练自己数据集遇到的各种问题
JMeter script parameterization
Error: NPM warn config global ` --global`, `--local` are deprecated Use `--location=global` instead.
Implement a server with multi process concurrency
kityformula-editor 配置字号和间距
Use of freemaker
Daily learning 2
Fabric. JS free draw circle
Fabric.js 自由绘制圆形
obsidian安装第三方插件——无法加载插件
MQ教程 | Exchange(交换机)
MathML to latex
Fabric.js 动态设置字号大小
Tujia muniao meituan has a discount match in summer. Will it be fragrant if the threshold is low?
[QNX Hypervisor 2.2用户手册]6.3 Guest与外部之间通信
求轮廓最大内接圆
buuctf-pwn write-ups (7)