当前位置:网站首页>2022.06.26(LC_6100_统计放置房子的方式数)
2022.06.26(LC_6100_统计放置房子的方式数)
2022-06-27 08:12:00 【Leeli9316】

方法:动态规划
class Solution {
public int countHousePlacements(int n) {
//状态:dp[i] 表示有i个地块时的放置房子方式数
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);
}
}
边栏推荐
- What are the specialties of database system engineers?
- 安装jenkins
- JS uses the while cycle to calculate how many years it will take to grow from 1000 yuan to 5000 yuan if the interest rate for many years of investment is 5%
- After working in a large factory for ten years with an annual salary of 400000 yuan, I was suddenly laid off. If the company wanted to abandon you, it wouldn't leave any kindness
- 淘宝虚拟产品开店教程之作图篇
- Etcd tutorial - Chapter 5 etcd etcdctl usage
- ACM course term summary
- 闭包问题
- Persistence mechanism of redis
- 若xn>0,且x(n+1)/xn>1-1/n(n=1,2,...),证明级数∑xn发散
猜你喜欢

洛谷刷题心得记录

Linux下Redis的安装

MySQL index details

No matter how good LCD and OLED display technologies are, they cannot replace this ancient display nixie tube

SIG associé: toutes les routes mènent à ue5

【10. 差分】

LVGL GUI GUIDER移植代码到STM32
![[batch dos-cmd command - summary and summary] - parameters%0,%1,%2,%[0-9],%0-9 in the batch command and batch command parameter position switching command shift, operator% usage in the DOS command](/img/05/19299c47d54d4ede95322b5a923093.png)
[batch dos-cmd command - summary and summary] - parameters%0,%1,%2,%[0-9],%0-9 in the batch command and batch command parameter position switching command shift, operator% usage in the DOS command
![[batch dos-cmd command - summary and summary] - output / display command - echo](/img/44/cddad70eeb756db15c19100c25c61a.png)
[batch dos-cmd command - summary and summary] - output / display command - echo

Redis五种基本类型
随机推荐
c#的初步认识
Win10 how to manage startup items?
淘宝虚拟产品开店教程之作图篇
【批处理DOS-CMD命令-汇总和小结】-将文件夹映射成虚拟磁盘——subst
【c ++ primer 笔记】第3章 字符串、向量和数组
Lvgl GUI guide porting code to stm32
[batch dos-cmd command - summary and summary] - how to distinguish the internal command and external command of CMD, and the difference between CMD command and run (win+r) command,
What are the specialties of database system engineers?
Is futures reverse documentary reliable?
若xn>0,且x(n+1)/xn>1-1/n(n=1,2,...),证明级数∑xn发散
并发编程JUC的AQS底层源码
Redis主从复制以及哨兵模式
How to view program running time (timer) in JS
Closure problem
ACM课程学期总结
正确的理解MySQL的MVCC
JS use the switch statement to output the corresponding English day of the week according to 1-7
How can I import data from Oracle into fastdfs?
SIG associé: toutes les routes mènent à ue5
JVM常见的垃圾收集器