Archives
Recent Posts
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
관리 메뉴

개발도생's Blog

[백준][Java] 16600_Contemporary Art 본문

BaekJoon

[백준][Java] 16600_Contemporary Art

개발도생 2023. 1. 31. 14:45

[백준] 16600_Contemporary Art 문제

 

16600번: Contemporary Art

At the Van Abbemuseum of modern and contemporary art in Eindhoven, we always look to present our muses in the most interesting way possible. Sometimes we have our work cut out for us. Today we are exploring whether we can modify one of our perfectly-square

www.acmicpc.net


16600, Contemporary Art


번역기를 돌려서 문제를 풀어보려 했지만, 무슨 말인지 전혀 모르겠었다.

 

그래서 입출력 내용들을 봤는데 이전에 풀었던 방법과 동일하게 풀면 될 거 같았다.

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		long N = Long.parseLong(br.readLine());
		
		System.out.println(4 * Math.sqrt(N));

	}
}

먼저 입력 값을 받아오기 위해 BufferedReader 객체를 사용했다.

 

[Java][Class] Bufferedreader

코딩 테스트 문제들을 풀다가 우연히 알게 된 Bufferedreader 객에 대해서 공부해봤다. Bufferedreader Class는, 이름과 같이 버퍼를 사용하는 클래스다. 일반적으로 알고 있던 Scanner Class는 사용자가 값을

nan-o-nuel-do.tistory.com

입력받은 값은 Long 타입의 변수에 Long.parseLong() 메서드로 형 변환 시켜서 저장해 주었다.

 

Long 타입을 사용한 이유는 문제에서 10의 18승 값이 입력될 수 있다는 명시를 해놨기 때문이다.

 

변수에 저장된 값은 Math Classsqrt() 메서드를 사용해 제곱근을 구해주었다.

 

제곱근은 곧 한 변의 길이이기 때문에 한 변의 길이에 곱하기 4를 해주면 정답이 출력되는 것을 확인할 수 있다.


입력해야 되는 값
출력 값


위와 같은 코드로 제출했을 때,

맞았습니다!!

'BaekJoon' 카테고리의 다른 글

[백준][Java] 5357_Dedupe  (0) 2023.03.19
[백준][Java] 5300_Fill the Rowboats!  (0) 2023.03.15
[백준][Java] 20353_Atrium  (0) 2023.01.30
[백준][Java] 25494_단순한 문제 (Small)  (2) 2023.01.28
[백준][Java] 16204_카드 뽑기  (6) 2022.12.22
Comments