Skip to content

Commit 7455b62

Browse files
committed
Java Algorithm
1 parent 5eacc38 commit 7455b62

File tree

7 files changed

+97
-18
lines changed

7 files changed

+97
-18
lines changed

.idea/workspace.xml

+22-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.
Binary file not shown.
Binary file not shown.

BOJ_JAVA/src/BOJ/BOJ_2858.java

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package BOJ;
2+
3+
import java.io.BufferedReader;
4+
import java.io.IOException;
5+
import java.io.InputStreamReader;
6+
import java.util.StringTokenizer;
7+
8+
public class BOJ_2858 {
9+
private static int R, B;
10+
public static void main(String[] args) throws IOException {
11+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
12+
StringTokenizer st = new StringTokenizer(br.readLine());
13+
14+
R = Integer.parseInt(st.nextToken());
15+
B = Integer.parseInt(st.nextToken());
16+
17+
for (int i = 3; i < 2000; i++) {
18+
for (int j = 3; j < i + 1; j++) {
19+
int tmp = (i * 2) + ((j - 2) * 2);
20+
if ((tmp == R) && ((i * j) - tmp) == B) {
21+
System.out.println(i + " " + j);
22+
}
23+
}
24+
}
25+
br.close();
26+
}
27+
28+
29+
/*
30+
10 2 >> 4 3
31+
12 3 >> 5 3
32+
14 4 >> 6 3
33+
16 9 >> 5 5
34+
*/
35+
}

BOJ_JAVA/src/BOJ/BOJ_3040.java

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package BOJ;
2+
3+
import java.io.BufferedReader;
4+
import java.io.IOException;
5+
import java.io.InputStreamReader;
6+
import java.util.Arrays;
7+
8+
public class BOJ_3040 {
9+
10+
private static int[] tmp, arr, ans;
11+
private static void Combination(int depth, int start, int sum) {
12+
if (depth == 7 && sum == 100) {
13+
ans = tmp.clone();
14+
return;
15+
} else if (depth == 7) return;
16+
17+
for (int i = start; i < 9; i++) {
18+
tmp[depth] = arr[i];
19+
Combination(depth + 1, i + 1, sum + arr[i]);
20+
}
21+
22+
}
23+
public static void main(String[] args) throws IOException {
24+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
25+
arr = new int[9];
26+
tmp = new int[7];
27+
ans = new int[7];
28+
29+
for (int i = 0; i < 9; i++) {
30+
arr[i] = Integer.parseInt(br.readLine());
31+
}
32+
33+
Combination(0, 0, 0);
34+
for (int i : ans) {
35+
System.out.println(i);
36+
}
37+
br.close();
38+
39+
}
40+
}

0 commit comments

Comments
 (0)