[Java | 백준 1085] 직사각형에서 탈출
· 테크· Java
Java
백준 1085 www.acmicpc.net/problem/1085
풀이
직사각형에서 탈출하기 위해서 가장 최단거리를 알아보기 위해 x, y축을 고려해본다. 생각이 안나면 간단히 좌표만 그려도 해결되는 문제이다.
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
int y = sc.nextInt();
int h = sc.nextInt();
int w = sc.nextInt();
sc.nextLine();
System.out.println(Math.min(Math.min(x, h-x), Math.min(y,w-y)));
sc.close();
}
}
|
cs |
Comments
No comments yet. Be the first!
319 posts in 테크
- 368Supabase 프로젝트 복사하기 (Restore to a New Project)NEW
- 341Migrating from Permanent Access Tokens to Token Exchange — Why Order Matters
- 326Startup & Product Glossary: Terms Every Solo Founder Should Know
- 325Context Management — How I Do It Now
- 324Claude Code Routines vs Cowork Schedule — What's the Difference?
1–5 / 319