본문 바로가기
Algorithm/Baekjoon

Baekjoon 15610 Abbey Courtyard JAVA

by Hunveloper 2022. 5. 4.
728x90
 

15610번: Abbey Courtyard

Bath’s annual Christmas market runs from the 23rd of November 2017 until the 10th of December 2017. During this time, the market will occupy the entire square courtyard of Bath Abbey. To brighten things up at night, a single long strand of cheerful festi

www.acmicpc.net

문제

Bath’s annual Christmas market runs from the 23rd of November 2017 until the 10th of December 2017. During this time, the market will occupy the entire square courtyard of Bath Abbey.

To brighten things up at night, a single long strand of cheerful festive lights will be run along all four equally long edges of the courtyard.

You will be in charge of buying the electrical wiring to which the lights will be affixed. How much will you need to use to outline the whole Christmas market with festive lights?

입력

The input consists of:

  • One line with an integer a (1 ≤ a ≤ 1018), the area in square metres of the yard.
출력

Output the total length of electrical wiring needed for the market, in metres. The length should be accurate to an absolute or relative error of at most 10^−6.

풀이

입력받는 값은 사각형 면적의 넓이이고, 구하는 것은 사각형의 길이이다.

입력값에 제곱근을 찾아 한 면의 길이를 구하고, 구한 길이에 *4를 하면 전체 둘레의 길이를 구할 수 있다.

코드
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println(Math.sqrt(sc.nextLong())*4);
}
}

 

728x90
728x90

'Algorithm > Baekjoon' 카테고리의 다른 글

Baekjoon 8723 Patyki JAVA  (0) 2022.05.04
Baekjoon 16600 Contemporary Art JAVA  (0) 2022.05.04
Baekjoon 14264 정육각형과 삼각형 JAVA  (0) 2022.05.04
Baekjoon 16486 운동장 한 바퀴 JAVA  (0) 2022.05.04
Baekjoon 1297 TV 크기 JAVA  (0) 2022.05.04

댓글