[백준] #1004 어린왕자 python
2022. 12. 31. 01:02
https://www.acmicpc.net/problem/1004
📕 설명 📕
출발점과 도착점을 기준으로 각각 접하거나 안에 있는 것이 있다면 count를 1씩 더하고 출력한다.
한 쪽만 접하거나 밖에 있을 경우 탈출하므로 count를 1 더해야 한다.
원의 방정식에 대한 성질을 알고 있다면 쉽게 풀 수 있었을 것이다.
🧑🏻💻 나의 풀이 🧑🏻💻
T = int(input())
for _ in range(T):
start_x, start_y, target_x, target_y = map(int, input().split())
count = 0
for j in range(int(input())):
other_x, other_y, other_r = map(int ,input().split())
circlr_distance_1 = ((start_x - other_x)**2 + (start_y - other_y)**2)**0.5
circlr_distance_2 = ((target_x - other_x)**2 + (target_y - other_y)**2)**0.5
if circlr_distance_1 < other_r and circlr_distance_2 > other_r or circlr_distance_1 > other_r and circlr_distance_2 < other_r:
count += 1
print(count)
'Programming > Algorithm' 카테고리의 다른 글
[백준] #1037 약수 python (0) | 2022.12.31 |
---|---|
[백준] #5086 배수와 약수 python (0) | 2022.12.31 |
[백준] #1002 터렛 python (0) | 2022.12.31 |
[백준] #3053 택시 기하학 python (0) | 2022.12.31 |
[백준] #2477 참외밭 python (0) | 2022.12.30 |