We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0ed1393 commit 5b447d7Copy full SHA for 5b447d7
1 file changed
Seol-JY/202507/14 G5 1,2,3더하기4.md
@@ -0,0 +1,31 @@
1
+```java
2
+import java.io.*;
3
+
4
+public class Main {
5
+ static int T;
6
+ static int[][] dp = new int[10_001][4];
7
8
+ public static void main(String[] args) throws IOException {
9
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
10
+ T = Integer.parseInt(br.readLine());
11
12
+ dp[1][1] = 1;
13
+ dp[2][1] = 1;
14
+ dp[2][2] = 1;
15
+ dp[3][1] = 1;
16
+ dp[3][2] = 1;
17
+ dp[3][3] = 1;
18
19
+ for (int j = 4; j <= 10000; j++) {
20
+ dp[j][1] = dp[j-1][1];
21
+ dp[j][2] = dp[j-2][1] + dp[j-2][2];
22
+ dp[j][3] = dp[j-3][1] + dp[j-3][2] + dp[j-3][3];
23
+ }
24
25
+ for (int i = 0; i < T; i++) {
26
+ int n = Integer.parseInt(br.readLine());
27
+ System.out.println(dp[n][1] + dp[n][2] + dp[n][3]);
28
29
30
+}
31
+```
0 commit comments