diff --git a/LeeTaeHo/boj/boj15817.java b/LeeTaeHo/boj/boj15817.java new file mode 100644 index 00000000..f637adf8 --- /dev/null +++ b/LeeTaeHo/boj/boj15817.java @@ -0,0 +1,28 @@ +import java.io.*; +import java.util.*; + +public class boj15817 { + + 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()); + int x = Integer.parseInt(st.nextToken()); + int[] pipe = new int[x + 1]; + pipe[0] = 1; + for (int i = 0; i < n; i++) { + st = new StringTokenizer(br.readLine()); + int length = Integer.parseInt(st.nextToken()); + int cnt = Integer.parseInt(st.nextToken()); + for (int j = x; j >= length; j--) { + for (int k = 1; k <= cnt; k++) { + if(j - length * k >= 0){ + pipe[j] += pipe[j - length * k]; + } + } + } + } + + System.out.println(pipe[x]); + } +} \ No newline at end of file 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]); + } +} diff --git a/LeeTaeHo/boj/boj2660.java b/LeeTaeHo/boj/boj2660.java new file mode 100644 index 00000000..1d787cd7 --- /dev/null +++ b/LeeTaeHo/boj/boj2660.java @@ -0,0 +1,66 @@ +import java.io.*; +import java.util.*; + +public class boj2660 { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int n = Integer.parseInt(br.readLine()); + int[][] dp = new int[n + 1][n + 1]; + + for (int i = 1; i <= n; i++) { + Arrays.fill(dp[i], 100000000); + dp[i][i] = 0; + } + + while (true) { + StringTokenizer st = new StringTokenizer(br.readLine()); + int p1 = Integer.parseInt(st.nextToken()); + int p2 = Integer.parseInt(st.nextToken()); + + if (p1 == -1 && p2 == -1) break; + + dp[p1][p2] = dp[p2][p1] = 1; + } + + for (int k = 1; k <= n; k++) { + for (int i = 1; i <= n; i++) { + for (int j = 1; j <= n; j++) { + if (dp[i][j] > dp[i][k] + dp[k][j]) { + dp[i][j] = dp[i][k] + dp[k][j]; + } + } + } + } + + int[] score = new int[n + 1]; + int minValue = 100000000; + + for (int i = 1; i <= n; i++) { + for (int j = 1; j <= n; j++) { + if (score[i] < dp[i][j]) { + score[i] = dp[i][j]; + } + } + if (minValue > score[i]) { + minValue = score[i]; + } + } + + StringBuilder sb = new StringBuilder(); + int cnt = 0; + List list = new ArrayList<>(); + for (int i = 1; i <= n; i++) { + if (score[i] == minValue) { + cnt++; + list.add(i); + } + } + + sb.append(minValue).append(" ").append(cnt).append("\n"); + for (int i : list) { + sb.append(i).append(" "); + } + + System.out.println(sb); + } +} \ No newline at end of file