-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #259 from leetaggg/main
이태호 / 10월 1주차 / 목
- Loading branch information
Showing
3 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |