File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ ``` java
2+ import java.io.* ;
3+ import java.util.* ;
4+
5+ public class boj3067 {
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 = 1 ; tc <= T ; tc++ ) {
15+ nextLine();
16+ int N = nextInt();
17+ int [] coins = new int [N + 1 ];
18+ nextLine();
19+ for (int i = 1 ; i <= N ; i++ ) coins[i] = nextInt();
20+ nextLine();
21+ int M = nextInt();
22+ int [][] dp = new int [N + 1 ][M + 1 ];
23+ for (int i = 1 ; i <= N ; i++ ) {
24+ dp[i][0 ] = 1 ;
25+ for (int j = 1 ; j <= M ; j++ ) {
26+ dp[i][j] = dp[i- 1 ][j];
27+ if (j >= coins[i]) dp[i][j] += dp[i][j- coins[i]];
28+ }
29+ }
30+ System . out. println(dp[N ][M ]);
31+ }
32+ }
33+ }
34+ ```
You can’t perform that action at this time.
0 commit comments