Skip to content

Commit 5b11a54

Browse files
authored
[20250808] BOJ / G5 / 1, 2, 3 더하기 4 / 김수연
1 parent f538bd1 commit 5b11a54

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
```java
2+
import java.io.*;
3+
import java.util.*;
4+
5+
public class boj15989 {
6+
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
7+
static StringTokenizer st;
8+
static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());}
9+
static int nextInt() {return Integer.parseInt(st.nextToken());}
10+
11+
public static void main(String[] args) throws Exception {
12+
nextLine();
13+
int T = nextInt();
14+
for (int tc = 0; tc < T; tc++) {
15+
nextLine();
16+
int n = nextInt();
17+
int[] dp = new int[n+1];
18+
dp[0] = 1;
19+
for (int i = 1; i <= 3; i++) {
20+
for (int j = i; j <= n; j++) {
21+
dp[j] += dp[j-i];
22+
}
23+
}
24+
System.out.println(dp[n]);
25+
}
26+
}
27+
}
28+
```

0 commit comments

Comments
 (0)