2024/12/8 灵茶题单 dp

This commit is contained in:
Cool 2024-12-08 18:09:42 +08:00
parent 26b0c8c863
commit 4319230aa4
1 changed files with 15 additions and 0 deletions

View File

@ -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);
}
}