Java/Java 알고리즘
백준 20215번 Cutting Corners JAVA 구현해보기
kimc
2022. 2. 13. 11:32
```
백준 20215번 Cutting Corners JAVA 구현해보기
```

이번 글을 통해 배워갈 내용
- 백준 20215번 풀이
https://www.acmicpc.net/problem/20215
20215번: Cutting Corners
A large coffee spill in the warehouse of the Busy Association of Papercutters on Caffeine has stained the corners of all paper in storage. In order to not waste money, it was decided that these dirty corners should be cut off of all pieces of paper. A few
www.acmicpc.net
백준 20215번은
난이도 브론즈 등급의 문제로서
사각형에 높이와 너비가 주어질 때
높이 + 너비 - 빗변을 소수점 6자리 정확도 이상으로 구해주면 되는 문제입니다.
30분 정도 위에 링크를 방문하셔서 풀어보시고
안 풀리시는 경우에만 아래 해답을 봐주시면 감사하겠습니다.
w + h - (w^2+h^2)^0.5로 구하였습니다.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
public static void main(String[] args) throws IOException {
StringTokenizer st = new StringTokenizer(br.readLine(), " ");
int cornerWidth = Integer.parseInt(st.nextToken());
int cornerHeight = Integer.parseInt(st.nextToken());
double len = cornerHeight + cornerWidth - Math.sqrt(cornerHeight * cornerHeight + cornerWidth * cornerWidth);
System.out.println(len);
}
}
읽어주셔서 감사합니다
무엇인가 얻어가셨기를 바라며
오늘도 즐거운 코딩 하시길 바랍니다 ~ :)
728x90