From a04a9d52c5a0e884f7c36af3890d10385075bd5f Mon Sep 17 00:00:00 2001 From: lkhyun <102892446+lkhyun@users.noreply.github.com> Date: Wed, 23 Jul 2025 15:14:03 +0900 Subject: [PATCH] =?UTF-8?q?[20250723]=20BOJ=20/=20G4=20/=20=EB=B0=B0?= =?UTF-8?q?=EC=88=98=20=EA=B3=B5=EC=82=AC=20/=20=EC=9D=B4=EA=B0=95?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...60\354\210\230\352\263\265\354\202\254.md" | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 "lkhyun/202507/23 BOJ G4 \353\260\260\354\210\230\352\263\265\354\202\254.md" diff --git "a/lkhyun/202507/23 BOJ G4 \353\260\260\354\210\230\352\263\265\354\202\254.md" "b/lkhyun/202507/23 BOJ G4 \353\260\260\354\210\230\352\263\265\354\202\254.md" new file mode 100644 index 00000000..914165f9 --- /dev/null +++ "b/lkhyun/202507/23 BOJ G4 \353\260\260\354\210\230\352\263\265\354\202\254.md" @@ -0,0 +1,43 @@ +```java +import java.util.*; +import java.io.*; + +public class Main{ + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + static StringTokenizer st; + static int N,X; + static int[] pipeLen; + static int[] pipeCnt; + static int[] dp; // dp[i] = 길이 i를 만드는 방법의 수 + + public static void main(String[] args) throws Exception { + st = new StringTokenizer(br.readLine()); + N = Integer.parseInt(st.nextToken()); + X = Integer.parseInt(st.nextToken()); + + pipeLen = new int[N]; + pipeCnt = new int[N]; + dp = new int[X+1]; + + for (int i = 0; i < N; i++) { + st = new StringTokenizer(br.readLine()); + pipeLen[i] = Integer.parseInt(st.nextToken()); + pipeCnt[i] = Integer.parseInt(st.nextToken()); + } + + dp[0] = 1; + for (int i = 0; i < N; i++) { //모든 파이프에 대하여 + for (int j = X; j >= 0; j--) { //길이를 고려 + for (int k = 1; k <= pipeCnt[i]; k++) { + if(j - pipeLen[i]*k >= 0){ + dp[j] += dp[j-pipeLen[i]*k]; + } + } + } + } + bw.write(dp[X]+""); + bw.close(); + } +} +```