Skip to content

Commit 14b4fc2

Browse files
committed
[20251005] BOJ / G4 / 타일 채우기 / 김민진
1 parent 68a0f9b commit 14b4fc2

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
```java
2+
import java.io.*;
3+
4+
public class BJ_2133_타일_채우기 {
5+
6+
private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
7+
private static final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
8+
9+
private static int N;
10+
private static int[] dp;
11+
12+
public static void main(String[] args) throws IOException {
13+
init();
14+
sol();
15+
}
16+
17+
private static void init() throws IOException {
18+
N = Integer.parseInt(br.readLine());
19+
dp = new int[N + 1];
20+
21+
if (N <= 1) return;
22+
23+
dp[0] = 1;
24+
dp[2] = 3;
25+
}
26+
27+
private static void sol() throws IOException {
28+
for (int i = 4; i <= N; i += 2) {
29+
dp[i] = dp[i - 2] * 4 - dp[i - 4];
30+
}
31+
bw.write(dp[N] + "\n");
32+
bw.flush();
33+
bw.close();
34+
br.close();
35+
}
36+
37+
}
38+
```

0 commit comments

Comments
 (0)