문제
A volcano has recently erupted in Geldingadalur, Iceland. Fortunately this eruption is relatively small, and---unlike the infamous Eyjafjallajökull eruption---is not expected to cause delayed international flights or global outrage.
There is some concern about the magmatic gas that has been released as part of the eruption, as it could pose danger to human populations in the surrounding area. Scientists have estimated the total amount of gas emitted, which, due to lack of wind, has spread out uniformly across a circular area around the centre of the volcano. The authorities have evacuated the area, and would now like to close it off by surrounding the perimeter with barrier tape.
입력
The input consists of:
- One line with an integer a (1≤a≤1018 ), the total area covered by gas in square metres.
출력
Output the total length of barrier tape needed to surround the area covered by gas, in metres. Your answer should have an absolute or relative error of at most 10^-6
풀이
가스가 확산된 구역의 넓이를 받고, 그 넓이를 둘러싸는 둘레의 길이를 구한다.
입력받은 값 : PI * R * R = x => R * R = x/PI => R = root(x/PI)
구해야하는 값 : 2 * PI * R => 2 * PI * root(x/PI) => 2 * root(pi) * root(x)
코드
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println(2*Math.pow(sc.nextDouble()*Math.PI, 0.5));
}
}
'Algorithm > Baekjoon' 카테고리의 다른 글
Baekjoon 16693 Pizza Deal JAVA (0) | 2022.05.10 |
---|---|
Baekjoon 20215 Cutting Corners JAVA (0) | 2022.05.05 |
Baekjoon 20352 Circus JAVA (0) | 2022.05.05 |
Baekjoon 1051 숫자 정사각형 JAVA (0) | 2022.05.04 |
Baekjoon 20353 Atrium JAVA (0) | 2022.05.04 |
댓글