2024/12/8 灵茶题单 dp
This commit is contained in:
parent
26b0c8c863
commit
4319230aa4
|
@ -0,0 +1,15 @@
|
|||
package com.cool.ling_cha_mount.dp;
|
||||
|
||||
public class Num2320 {
|
||||
public int countHousePlacements(int n) {
|
||||
int[] dp = new int[n + 2];
|
||||
final int MOD = 1000000007;
|
||||
dp[0] = 1;
|
||||
dp[1] = 1;
|
||||
for (int i = 0; i < dp.length - 2; i++) {
|
||||
dp[i + 2] = dp[i + 1] + dp[i];
|
||||
dp[i + 2] %= MOD;
|
||||
}
|
||||
return (int) ((long) dp[dp.length - 1] * dp[dp.length - 1] % MOD);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue