Skip to content

Commit 0542c75

Browse files
authored
Merge pull request #901 from AlgorithmWithGod/JHLEE325
[20250916] BOJ / G4 / 사다리 / 이준희
2 parents 30e59b7 + daa21dc commit 0542c75

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
```java
2+
import java.io.*;
3+
import java.util.*;
4+
5+
public class Main {
6+
static double x, y, c;
7+
8+
public static void main(String[] args) throws IOException {
9+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
10+
StringTokenizer st = new StringTokenizer(br.readLine());
11+
x = Double.parseDouble(st.nextToken());
12+
y = Double.parseDouble(st.nextToken());
13+
c = Double.parseDouble(st.nextToken());
14+
15+
double left = 0.0;
16+
double right = Math.min(x, y);
17+
double ans = 0.0;
18+
19+
for (int i = 0; i < 10000; i++) {
20+
double mid = (left + right) / 2.0;
21+
double h1 = Math.sqrt(x * x - mid * mid);
22+
double h2 = Math.sqrt(y * y - mid * mid);
23+
double tempc = (h1 * h2) / (h1 + h2);
24+
if (tempc >= c) {
25+
ans = mid;
26+
left = mid;
27+
} else {
28+
right = mid;
29+
}
30+
}
31+
32+
System.out.printf("%.3f\n", ans);
33+
}
34+
}
35+
```

0 commit comments

Comments
 (0)