Skip to content

Commit 8b0838c

Browse files
authored
[20251106] BOJ / G1 / 계단 수 / 한종욱
1 parent 57f3119 commit 8b0838c

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
```
2+
import java.io.*;
3+
import java.util.*;
4+
5+
public class Main {
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+
private static final int MOD = 1000000000;
9+
private static int[][][] dp;
10+
private static int N;
11+
public static void main(String[] args) throws IOException {
12+
init();
13+
long answer = 0;
14+
for (int i = 0; i < 10; i++) {
15+
answer += dp[N][i][(1<<10) - 1];
16+
answer %= MOD;
17+
}
18+
19+
bw.write(answer + "\n");
20+
bw.flush();
21+
bw.close();
22+
br.close();
23+
}
24+
25+
private static void init() throws IOException {
26+
N = Integer.parseInt(br.readLine());
27+
28+
dp = new int[N+1][10][1<<10];
29+
30+
for (int i = 1; i < 10; i++) {
31+
dp[1][i][1<<i] = 1;
32+
}
33+
34+
for (int i = 2; i <= N; i++) {
35+
for (int j = 0; j < 10; j++) {
36+
for (int k = 0; k < 1<<10; k++) {
37+
if (j < 9) {
38+
dp[i][j+1][k | (1<<(j+1))] += dp[i-1][j][k];
39+
dp[i][j+1][k | (1<<(j+1))] %= MOD;
40+
}
41+
if (j > 0) {
42+
dp[i][j-1][k | (1<<(j-1))] += dp[i-1][j][k];
43+
dp[i][j-1][k | (1<<(j-1))] %= MOD;
44+
}
45+
}
46+
}
47+
}
48+
}
49+
}
50+
```

0 commit comments

Comments
 (0)