当前位置:网站首页>June 26, 2022 (LC 6100 counts the number of ways to place houses)
June 26, 2022 (LC 6100 counts the number of ways to place houses)
2022-06-27 08:25:00 【Leeli9316】

Method : Dynamic programming
class Solution {
public int countHousePlacements(int n) {
// state :dp[i] Express i Number of ways to place houses when parcels
long[] dp = new long[n + 1];
dp[0] = 1;
dp[1] = 2;
for (int i = 2; i <= n; i++) {
dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007;
}
return (int)(dp[n] * dp[n] % 1000000007);
}
}
边栏推荐
猜你喜欢
![[batch dos-cmd command - summary and summary] - environment variables, path variables, search file location related instructions - set, path, where, what if there are spaces in the path parameters of](/img/ca/0b96294336810187e833429fcea5bf.png)
[batch dos-cmd command - summary and summary] - environment variables, path variables, search file location related instructions - set, path, where, what if there are spaces in the path parameters of

C how to call line and rows when updating the database

Redis五种基本类型

UE5神通--POI解决方案

05 观察者(Observer)模式

粗读DS-TransUNet: Dual Swin Transformer U-Net for Medical Image Segmentation

并发编程JUC的AQS底层源码

MySQL索引详解

一种太阳能电荷泵供电电路的方案设计

Eight misunderstandings, broken one by one (final): the cloud is difficult to expand, the customization is poor, and the administrator will lose control?
随机推荐
What is futures reverse documentary?
Filter filter
MSSQL how to export and delete multi table data using statements
L'introduction en bourse de Wild Wind Pharmaceutical a pris fin: Yu pinzeng, qui avait l'intention de lever 540 millions de RMB, a effectué un investissement P2P.
索引+sql练习优化
Order by injection of SQL injection
[13. number and bit operation of 1 in binary]
JS EventListener
100% understanding of 5 IO models
C how to call line and rows when updating the database
Import and export database related tables from the win command line
Code source AQS sous - jacent pour la programmation simultanée juc
关于el-date-picker点击清空参数变为null的问题
All tutor information on one page
No matter how good LCD and OLED display technologies are, they cannot replace this ancient display nixie tube
【批处理DOS-CMD命令-汇总和小结】-输出/显示命令——echo
【原创】TypeScript字符串utf-8编码解码
【10. 差分】
参考 | Win11 开启热点之后电脑不能上网
SQL Sever column name or number of supplied values does not match the table definition