반응형
백준 15751
15751번: Teleportation
The first and only line of input contains four space-separated integers: $a$ and $b$, describing the start and end locations, followed by $x$ and $y$, describing the teleporter. All positions are integers in the range $0 \ldots 100$, and they are not neces
www.acmicpc.net
import java.util.Scanner;
public class Main {
// USACO Teleportation JAVA
// 백준 15751
/**
*
*/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int start = sc.nextInt();
int end = sc.nextInt();
int x = sc.nextInt();
int y = sc.nextInt();
int case1 = Math.abs(end - start);
int case2 = Math.abs(start-x) + Math.abs(end-y);
int case3 = Math.abs(start-y) + Math.abs(end-x);
int answer = Math.min(case1, Math.min(case2, case3));
System.out.print(answer);
}//main
}//class
반응형
'개발 > 알고리즘' 카테고리의 다른 글
프로그래머스 체육복 (0) | 2021.03.11 |
---|---|
[USACO] 소가 길을 건너간 이유 3 백준 14469 (0) | 2021.02.26 |
[USACO] Word Processor JAVA (0) | 2021.02.24 |
[USACO] Just Stalling JAVA (0) | 2021.02.23 |
[USACO] Mad Scientist JAVA (0) | 2021.02.23 |
최근댓글