[백준_1085] 직사각형에서 탈출 성공 - JAVA

jm_25·2021년 11월 21일
0

알고리즘

목록 보기
10/40
post-thumbnail

문제 출처

https://www.acmicpc.net/problem/1085

풀이

  • 경계선까지의 최솟값을 구하면 되는 문제
  • 수학 문제

코드

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer stringTokenizer = new StringTokenizer(bufferedReader.readLine());
        int x = Integer.parseInt(stringTokenizer.nextToken());
        int y = Integer.parseInt(stringTokenizer.nextToken());
        int w = Integer.parseInt(stringTokenizer.nextToken());
        int h = Integer.parseInt(stringTokenizer.nextToken());
        System.out.println(Math.min(Math.min(x, y), Math.min(h-y, w-x)));
    }
}

채점 결과

profile
매일 매일 한 개씩

0개의 댓글