Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

이태호 / 10월 1주차 / 목 #259

Merged
merged 3 commits into from
Oct 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}