From 403bd043a1d89b504b7fbe48b292e514d343963e Mon Sep 17 00:00:00 2001 From: leetag1163 Date: Thu, 5 Oct 2023 09:34:02 +0900 Subject: [PATCH] [solved] boj18427 --- LeeTaeHo/boj/boj18427.java | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 LeeTaeHo/boj/boj18427.java diff --git a/LeeTaeHo/boj/boj18427.java b/LeeTaeHo/boj/boj18427.java new file mode 100644 index 00000000..0176f47e --- /dev/null +++ b/LeeTaeHo/boj/boj18427.java @@ -0,0 +1,40 @@ +import java.io.*; +import java.util.*; + +public class boj18427 { + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + int n = Integer.parseInt(st.nextToken()); + st.nextToken(); + int h = Integer.parseInt(st.nextToken()); + + int[] dp = new int[h + 1]; + + List[] block = new ArrayList[n + 1]; + + for (int i = 1; i <= n; i++) { + block[i] = new ArrayList<>(); + st = new StringTokenizer(br.readLine()); + while (st.hasMoreTokens()){ + block[i].add(Integer.parseInt(st.nextToken())); + } + } + + dp[0] = 1; + + for (int i = 1; i <= n; i++) { + for (int j = h; j >= 0; j--) { + for (int k : block[i]) { + if(j - k >= 0){ + dp[j] += dp[j - k]; + dp[j] %= 10007; + } + } + } + } + + System.out.println(dp[h]); + } +}