From a824447760dfbabc3cdedaa5b0de76904f34f836 Mon Sep 17 00:00:00 2001 From: Jonghwan Lee <123362165+0224LJH@users.noreply.github.com> Date: Sun, 24 Aug 2025 21:37:51 +0900 Subject: [PATCH] =?UTF-8?q?[20250824]=20BOJ=20/=20G5=20/=20=EB=8F=99?= =?UTF-8?q?=EC=A0=84=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 --- .../24 BOJ \353\217\231\354\240\204.md" | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 "0224LJH/202508/24 BOJ \353\217\231\354\240\204.md" diff --git "a/0224LJH/202508/24 BOJ \353\217\231\354\240\204.md" "b/0224LJH/202508/24 BOJ \353\217\231\354\240\204.md" new file mode 100644 index 00000000..257bf8ac --- /dev/null +++ "b/0224LJH/202508/24 BOJ \353\217\231\354\240\204.md" @@ -0,0 +1,57 @@ +```java +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.*; + + +public class Main { + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static int coinCnt,goal,ans; + static int[] coin,dp; + + + + public static void main(String[] args) throws IOException { + int TC = Integer.parseInt(br.readLine()); + for (int tc = 1; tc <= TC; tc++) { + init(); + process(); + print(); + } + } + + public static void init() throws IOException { + coinCnt = Integer.parseInt(br.readLine()); + coin = new int[coinCnt]; + ans = 0; + + StringTokenizer st = new StringTokenizer(br.readLine()); + for (int i = 0; i < coinCnt; i++) { + coin[i] = Integer.parseInt(st.nextToken()); + } + goal = Integer.parseInt(br.readLine()); + dp = new int[goal+1]; + dp[0] = 1; + + } + + public static void process() { + for (int i = 0; i < coinCnt; i++) { + int num = coin[i]; + for (int j = 0; j <= goal - num; j++) { + dp[j+num] += dp[j]; + } + } + ans = dp[goal]; + + } + + + + + public static void print() { + System.out.println(ans); + } +} +```