当前位置:网站首页>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;
}
};
边栏推荐
- A white hole formed by antineutrons produced by particle accelerators
- 由粒子加速器产生的反中子形成的白洞
- taobao.trades.sold.get-查询卖家已卖出的交易数据(根据创建时间),淘宝店铺卖出订单查询API接口,淘宝R2接口,淘宝oAuth2.0交易接口代码分享
- Fabric. JS upper dash, middle dash (strikethrough), underline
- Introduction to mathjax (web display of mathematical formulas, vector)
- taobao.logistics.dummy.send( 无需物流发货处理 )接口,淘宝店铺发货API接口,淘宝订单发货接口,淘宝r2接口,淘宝oAu2.0接口
- STM32-DAC实验&高频DAC输出测试
- Fabric.js 橡皮擦的用法(包含恢复功能)
- Fatal: unsafe repository is owned by someone else
- 【NOI模拟赛】伊莉斯elis(贪心,模拟)
猜你喜欢
广州市应急管理局发布7月高温高湿化工安全提醒
Yyds dry goods inventory software encryption lock function
Xilinx Vivado set *.svh as SystemVerilog Header
富文本编辑器添加矢量公式(MathType for TinyMCE ,可视化添加)
Thoroughly master prototype__ proto__、 Relationship before constructor (JS prototype, prototype chain)
Advanced C language (realize simple address book)
Fabric.js 上划线、中划线(删除线)、下划线
【空间&单细胞组学】第1期:单细胞结合空间转录组研究PDAC肿瘤微环境
Large top heap, small top heap and heap sequencing
A white hole formed by antineutrons produced by particle accelerators
随机推荐
1. Editing weapon VIM
MQ tutorial | exchange (switch)
taobao.logistics.dummy.send( 无需物流发货处理 )接口,淘宝店铺发货API接口,淘宝订单发货接口,淘宝r2接口,淘宝oAu2.0接口
一张图彻底掌握prototype、__proto__、constructor之前的关系(JS原型、原型链)
Stm32-dac Experiment & high frequency DAC output test
Fabric.js 上划线、中划线(删除线)、下划线
MFC CString 转 char*
Fabric. Keep the original level when JS element is selected
qml 弹窗框架,可定制
Implement a server with multi process concurrency
Actual combat sharing of shutter screen acquisition
The use of TestNG, the testing framework (II): the use of TestNG XML
LeetCode 2310. 个位数字为 K 的整数之和
Makefile separates file names and suffixes
广州市应急管理局发布7月高温高湿化工安全提醒
Thoroughly master prototype__ proto__、 Relationship before constructor (JS prototype, prototype chain)
taobao.trade.memo.add( 对一笔交易添加备注 )接口,淘宝店铺插旗接口,淘宝订单插旗API接口,oAuth2.0接口
Factal: Unsafe repository is owned by someone else Solution
记一次报错解决经历依赖重复
tmall.product.schema.get( 产品信息获取schema获取 ),淘宝店铺上传商品API接口,淘宝商品发布接口,淘宝商品上传API接口,店铺上传接口,oAuth2.0接口