From 8d24c38cf1376a083b5b2d0dcf17ca431a9d62c1 Mon Sep 17 00:00:00 2001 From: Jonghwan Lee <123362165+0224LJH@users.noreply.github.com> Date: Fri, 5 Sep 2025 21:03:23 +0900 Subject: [PATCH] =?UTF-8?q?[20250905]=20BOJ=20/=20G4=20/=20=EB=8F=99?= =?UTF-8?q?=EC=A0=841=20/=20=EC=9D=B4=EC=A2=85=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../202509/05 BOJ \353\217\231\354\240\2041" | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 "0224LJH/202509/05 BOJ \353\217\231\354\240\2041" diff --git "a/0224LJH/202509/05 BOJ \353\217\231\354\240\2041" "b/0224LJH/202509/05 BOJ \353\217\231\354\240\2041" new file mode 100644 index 00000000..1a465a27 --- /dev/null +++ "b/0224LJH/202509/05 BOJ \353\217\231\354\240\2041" @@ -0,0 +1,57 @@ +```java +import java.io.IOException; +import java.io.*; +import java.util.*; + + +public class Main { + static int[] dp,coins; + static int coinCnt, goal; + + public static void main(String[] args) throws IOException { + init(); + process(); + print(); + } + + public static void init() throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + coinCnt = Integer.parseInt(st.nextToken()); + goal = Integer.parseInt(st.nextToken()); + + coins = new int[coinCnt]; + dp = new int[goal+1]; + dp[0] = 1; + + for (int i = 0; i < coinCnt; i++) { + coins[i] = Integer.parseInt(br.readLine()); + } + + + } + + public static void process() throws IOException { + + for (int i = 0; i < coinCnt; i++) { + int cost = coins[i]; + + for (int j = cost; j <= goal; j++) { + dp[j] += dp[j-cost]; + } + } + + } + + + + + + + + public static void print() { + System.out.println(dp[goal]); + } +} + +```