λ¬Έμ
https://www.acmicpc.net/problem/1002
1002λ²: ν°λ
κ° ν μ€νΈ μΌμ΄μ€λ§λ€ λ₯μ¬λͺ μ΄ μμ μ μλ μμΉμ μλ₯Ό μΆλ ₯νλ€. λ§μ½ λ₯μ¬λͺ μ΄ μμ μ μλ μμΉμ κ°μκ° λ¬΄νλμΌ κ²½μ°μλ -1μ μΆλ ₯νλ€.
www.acmicpc.net
νμ΄
# λ°±μ€ 1002λ² λ¬Έμ - ν°λ
import math
n = int(input())
for _ in range(n):
x1, y1, r1, x2, y2, r2 = map(int, input().split())
distance = math.sqrt((x1-x2)**2 + (y1-y2)**2) # λ μμ 거리 (μμλ°©μ μνμ©)
if distance == 0 and r1 == r2 : # λ μμ΄ λμ¬μμ΄κ³ λ°μ§λ¦μ΄ κ°μ λ
print(-1)
elif abs(r1-r2) == distance or r1 + r2 == distance: # λ΄μ , μΈμ μΌ λ
print(1)
elif abs(r1-r2) < distance < (r1+r2) : # λ μμ΄ μλ‘λ€λ₯Έ λ μ μμ λ§λ λ
print(2)
else:
print(0) # κ·Έ μΈμ
μ€λλ§μ μνμ μΈ λ¬Έμ κ° λμμ μμ 곡λΆνλ€..
'ποΈ Algorithm > π© λ°±μ€' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
π© [λ°±μ€] [Python] [BFS] 7576λ²_ν λ§ν (0) | 2022.11.07 |
---|---|
π© [λ°±μ€] [Python] [BFS] 1926λ²_κ·Έλ¦Ό (0) | 2022.11.07 |
π© [λ°±μ€] [Python] 1629λ²_κ³±μ (0) | 2022.11.07 |
π© [λ°±μ€] [Python] 1182λ²_λΆλΆμμ΄μ ν© (0) | 2022.11.07 |
π© [λ°±μ€] [Python] [Class3] 1074λ²_Z (0) | 2022.11.07 |