We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2ef3e56 commit 1dcde56Copy full SHA for 1dcde56
Seol-JY/202502/23 BOJ G4 타일 채우기 3.md
@@ -0,0 +1,24 @@
1
+```java
2
+import java.io.*;
3
+public class Main {
4
+ static int N;
5
+ static final int MOD = 1000000007;
6
+ static long[][] dp = new long[1000001][2];
7
+
8
+ public static void main(String[] args) throws IOException {
9
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
10
+ N = Integer.parseInt(br.readLine());
11
+ dp[0][0] = 0;
12
+ dp[1][0] = 2;
13
+ dp[2][0] = 7;
14
+ dp[2][1] = 1;
15
16
+ for (int i = 3; i <= N; i++) {
17
+ dp[i][1] = (dp[i - 3][0] + dp[i - 1][1]) % MOD; // i - 3 까지 누적합 + 1
18
+ dp[i][0] = (3 * (dp[i - 2][0]) + 2 * (dp[i - 1][0]) + 2 * dp[i][1]) % MOD;
19
+ }
20
21
+ System.out.println(dp[N][0]);
22
23
+}
24
+```
0 commit comments