Skip to content

Commit 524c991

Browse files
authored
[20251218] BOJ / G5 / 1, 2, 3 더하기 4 / 김민진
1 parent 89a7de8 commit 524c991

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
```java
2+
import java.io.*;
3+
4+
public class Main {
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+
private static final StringBuilder sb = new StringBuilder();
9+
10+
private static int[] dp;
11+
12+
public static void main(String[] args) throws IOException {
13+
int T = Integer.parseInt(br.readLine());
14+
15+
init();
16+
17+
while (T-- > 0) {
18+
sol();
19+
}
20+
21+
bw.write(sb.toString());
22+
bw.flush();
23+
bw.close();
24+
br.close();
25+
}
26+
27+
private static void init() {
28+
dp = new int[10001];
29+
dp[0] = 1;
30+
31+
for (int num : new int[]{1, 2, 3}) {
32+
for (int i = num; i <= 10000; i++) {
33+
dp[i] += dp[i - num];
34+
}
35+
}
36+
}
37+
38+
private static void sol() throws IOException {
39+
int n = Integer.parseInt(br.readLine());
40+
sb.append(dp[n]).append("\n");
41+
}
42+
}
43+
```

0 commit comments

Comments
 (0)