File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 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+ ```
You can’t perform that action at this time.
0 commit comments