반응형

Prob


Approach

상황별 예외조건을 적용한다.

원일 경우 -1, 만날 수 없는 경우 0, 직선거리에 있는 경우 1, 그 외 2.

x, y 좌표가 -가 나올 수 있기 때문에 그 부분도 신경쓴다.


Code

import math

if __name__ == "__main__" :
    T = int(input())

    for i in range(T):
        x1, y1, r1, x2, y2, r2 = map(int, input().split())
        distance = math.sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2))
        if distance == 0 and r1 == r2:
            print(-1)
        elif distance == 0:
            print(0)
        elif r1 + r2 < distance or distance < abs(r1 - r2):
            print(0)
        elif r1 + r2 == distance or distance == abs(r1 - r2):
            print(1)
        else:
            print(2)

 

출처

https://www.acmicpc.net/problem/1002

반응형
블로그 이미지

Refrin

일상생활 끄적 IT 프로젝트 끄적