main
[백준-1004번/Java] 어린왕자 본문
* 출발점/도착점 중 하나만 원 내부에 있는 경우만 count를 센다.
* 하나의 원 안에 출발점과 도착점이 모두있는 경우에는, 원을 지나지 않고 도착할 수 있으므로 count를 세지 않는다.
* 기하학
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
Scanner scan = new Scanner(System.in);
int T = scan.nextInt();
for (int i = 0; i < T; i++) {
int x1 = scan.nextInt();
int y1 = scan.nextInt();
int x2 = scan.nextInt();
int y2 = scan.nextInt();
int count = 0;
int N = scan.nextInt();
for (int j = 0; j < N; j++) {
int cx = scan.nextInt();
int cy = scan.nextInt();
int r = scan.nextInt();
if (Math.pow(r, 2) >= Math.pow(cx - x1, 2) + Math.pow(cy - y1, 2)
&& Math.pow(r, 2) >= Math.pow(cx - x2, 2) + Math.pow(cy - y2, 2)) {
} else if (Math.pow(r, 2) >= Math.pow(cx - x1, 2) + Math.pow(cy - y1, 2)
|| Math.pow(r, 2) >= Math.pow(cx - x2, 2) + Math.pow(cy - y2, 2)) {
count++;
}
}
System.out.println(count);
}
scan.close();
}
}
728x90
'Algorithm' 카테고리의 다른 글
[백준-2564번/Java] 경비원 (0) | 2022.11.13 |
---|---|
[백준-2563번/Java] 색종이 (0) | 2022.11.13 |
[백준-2775번/Java] 부녀회장이 될테야 (0) | 2022.11.12 |
[백준-2108번/Java] 통계학 (0) | 2022.11.12 |
[백준-13458번/Java] 시험 감독 (0) | 2022.11.12 |
Comments