File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ ``` java
2+ import java.io.BufferedReader ;
3+ import java.io.InputStreamReader ;
4+ import java.io.IOException ;
5+ import java.util.StringTokenizer ;
6+
7+ public class Main {
8+ private static BufferedReader br;
9+
10+ public static void main (String [] args ) throws IOException {
11+ br = new BufferedReader (new InputStreamReader (System . in));
12+ int T = Integer . parseInt(br. readLine());
13+ StringTokenizer st;
14+ StringBuilder sb = new StringBuilder ();
15+
16+ for (int tc = 0 ; tc < T ; tc++ ) {
17+ int n = Integer . parseInt(br. readLine());
18+ int [] coins = new int [n];
19+ st = new StringTokenizer (br. readLine());
20+
21+ for (int i = 0 ; i < n; i++ ) {
22+ coins[i] = Integer . parseInt(st. nextToken());
23+ }
24+ int target = Integer . parseInt(br. readLine());
25+ int [] dp = new int [target + 1 ]; // dp[i] i원을 만드는 경우의수
26+ dp[0 ] = 1 ;
27+ for (int coin : coins) {
28+ for (int amount = coin; amount <= target; amount++ ) {
29+ dp[amount] += dp[amount - coin];
30+ }
31+ }
32+ sb. append(dp[target]). append(' \n ' );
33+ }
34+ System . out. print(sb. toString());
35+ br. close();
36+ }
37+ }
38+ ```
You can’t perform that action at this time.
0 commit comments