직사각형에서 도망가~
점과 가장 가까운 거리를 구하면 풀리는 문제였다. 솔직히 아까 풀었던 주사위 문제보다 훨씬 쉬웠다.
난이도 조정 좀 줘야될듯..
package org.example;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
String s = bf.readLine();
String[] split = s.split(" ");
List<Integer> array = new ArrayList<>();
int x = Integer.parseInt(split[0]);
int y = Integer.parseInt(split[1]);
int w = Integer.parseInt(split[2]);
int h = Integer.parseInt(split[3]);
int num1 = x - 0;
int num2 = y - 0;
int num3 = w - x;
int num4 = h - y;
array.add(num1);
array.add(num2);
array.add(num3);
array.add(num4);
Integer min = Collections.min(array);
System.out.println(min);
}
}
'PS > 백준' 카테고리의 다른 글
백준 - 삼각형 외우기 (0) | 2023.11.12 |
---|---|
백준 - 알고리즘 수업 - 피보나치 수1 (0) | 2023.11.12 |
백준 - 주사위 세개 (0) | 2023.11.11 |
백준 - 최소공배수 (0) | 2023.11.10 |
백준 - 최대공약수와 최소공배수 (0) | 2023.11.10 |
댓글