Skip to content

Commit abcaa18

Browse files
authored
[20260117] BOJ / G5 / 알약 / 한종욱
1 parent 2adbd00 commit abcaa18

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

Ukj0ng/202601/17 BOJ G5 알약.md

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

0 commit comments

Comments
 (0)