[Java | 백준 3009] 네 번째 점
· 테크· Java
Java
백준 3009 www.acmicpc.net/problem/3009
풀이
이 방법이 좋다고는 볼 수 없지만 단순하게 말해서 주어진 문제의 x 좌표 값이 일치하는 두 개가 있고 나머지 하나가 정답의 x 좌표가 될 것이다. 직사각형이니까 y 좌표역시 동일하게 구해주었다.
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
import java.util.Scanner;
public class Math_3009 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int x1=0,x2=0,x3=0,y1=0,y2=0,y3=0;
x1 = sc.nextInt();
y1 = sc.nextInt();
x2 = sc.nextInt();
y2 = sc.nextInt();
x3 = sc.nextInt();
y3 = sc.nextInt();
sc.nextLine();
int a = 0, b = 0;
if(x1==x2) a=x3;
else if(x1==x3) a=x2;
if(x2==x3) a=x1;
if(y1==y2) b=y3;
else if(y1==y3) b=y2;
if(y2==y3) b=y1;
System.out.println(a+" "+b);
sc.close();
}
}
|
cs |
다른 풀이
나와 동일하게 풀이를 하신 분들도 있었는데 다른 방법을 찾고 싶어 보던 중
세 값을 Map으로 받아서 count 값이 1일 때의 x, y 좌표를 구하는 방법도 있다는 것을 알 수 있었다. 아래 링크 참조
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