본문 바로가기

Algorithm

[python] 백준 1002번 : 터렛

import sys
import math
num=int(sys.stdin.readline())
for num in range(num):
    x1, y1, r1, x2, y2, r2=map(int, sys.stdin.readline().split())
    d=math.sqrt((x2-x1)**2+(y2-y1)**2)

    if x1==x2 and y2==y1:
        if r1==r2:
            print(-1)
        else:
            print(0)
    else:
        if (d==r1+r2 or d==abs(r1-r2)):
            print(1)
        elif(d<r1+r2 and d>abs(r1-r2)):
            print(2)
        else:
            print(0)

2022.05.08에 푼 문제..