From e632f61bc3d8f2088e596e9c74222a4cab68a93f Mon Sep 17 00:00:00 2001 From: suyeun84 <81475092+suyeun84@users.noreply.github.com> Date: Sat, 2 Aug 2025 22:50:42 +0900 Subject: [PATCH] =?UTF-8?q?[20250802]=20BOJ=20/=20G5=20/=20Coins=20/=20?= =?UTF-8?q?=EA=B9=80=EC=88=98=EC=97=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- suyeun84/202508/02 BOJ Coins.md | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 suyeun84/202508/02 BOJ Coins.md diff --git a/suyeun84/202508/02 BOJ Coins.md b/suyeun84/202508/02 BOJ Coins.md new file mode 100644 index 00000000..eb1b7eaf --- /dev/null +++ b/suyeun84/202508/02 BOJ Coins.md @@ -0,0 +1,34 @@ +```java +import java.io.*; +import java.util.*; + +public class boj3067 { + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static StringTokenizer st; + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static int nextInt() {return Integer.parseInt(st.nextToken());} + + public static void main(String[] args) throws Exception { + nextLine(); + int T = nextInt(); + for (int tc = 1; tc <= T; tc++) { + nextLine(); + int N = nextInt(); + int[] coins = new int[N+1]; + nextLine(); + for (int i = 1; i <= N; i++) coins[i] = nextInt(); + nextLine(); + int M = nextInt(); + int[][] dp = new int[N+1][M+1]; + for (int i = 1; i <= N; i++) { + dp[i][0] = 1; + for (int j = 1; j <= M; j++) { + dp[i][j] = dp[i-1][j]; + if (j >= coins[i]) dp[i][j] += dp[i][j-coins[i]]; + } + } + System.out.println(dp[N][M]); + } + } +} +```