Skip to content

Commit

Permalink
Merge pull request #259 from leetaggg/main
Browse files Browse the repository at this point in the history
이태호 / 10월 1주차 / 목
  • Loading branch information
leetaggg authored Oct 22, 2023
2 parents 57d09e1 + 403bd04 commit 554815f
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 0 deletions.
28 changes: 28 additions & 0 deletions LeeTaeHo/boj/boj15817.java
Original file line number Diff line number Diff line change
@@ -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]);
}
}
40 changes: 40 additions & 0 deletions LeeTaeHo/boj/boj18427.java
Original file line number Diff line number Diff line change
@@ -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<Integer>[] 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]);
}
}
66 changes: 66 additions & 0 deletions LeeTaeHo/boj/boj2660.java
Original file line number Diff line number Diff line change
@@ -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<Integer> 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);
}
}

0 comments on commit 554815f

Please sign in to comment.