[๋ฐฑ์ค€/python] 1002๋ฒˆ : ํ„ฐ๋ ›

2021. 4. 13. 21:57

๋ฌธ์ œ

์กฐ๊ทœํ˜„๊ณผ ๋ฐฑ์Šนํ™˜์€ ํ„ฐ๋ ›์— ๊ทผ๋ฌดํ•˜๋Š” ์ง์›์ด๋‹ค. ํ•˜์ง€๋งŒ ์›Œ๋‚™ ์กด์žฌ๊ฐ์ด ์—†์–ด์„œ ์ธ๊ตฌ์ˆ˜๋Š” ์ฐจ์ง€ํ•˜์ง€ ์•Š๋Š”๋‹ค. ๋‹ค์Œ์€ ์กฐ๊ทœํ˜„๊ณผ ๋ฐฑ์Šนํ™˜์˜ ์‚ฌ์ง„์ด๋‹ค.

์ด์„์›์€ ์กฐ๊ทœํ˜„๊ณผ ๋ฐฑ์Šนํ™˜์—๊ฒŒ ์ƒ๋Œ€ํŽธ ๋งˆ๋ฆฐ(๋ฅ˜์žฌ๋ช…)์˜ ์œ„์น˜๋ฅผ ๊ณ„์‚ฐํ•˜๋ผ๋Š” ๋ช…๋ น์„ ๋‚ด๋ ธ๋‹ค. ์กฐ๊ทœํ˜„๊ณผ ๋ฐฑ์Šนํ™˜์€ ๊ฐ๊ฐ ์ž์‹ ์˜ ํ„ฐ๋ › ์œ„์น˜์—์„œ ํ˜„์žฌ ์ ๊นŒ์ง€์˜ ๊ฑฐ๋ฆฌ๋ฅผ ๊ณ„์‚ฐํ–ˆ๋‹ค.

์กฐ๊ทœํ˜„์˜ ์ขŒํ‘œ (x1, y1)์™€ ๋ฐฑ์Šนํ™˜์˜ ์ขŒํ‘œ (x2, y2)๊ฐ€ ์ฃผ์–ด์ง€๊ณ , ์กฐ๊ทœํ˜„์ด ๊ณ„์‚ฐํ•œ ๋ฅ˜์žฌ๋ช…๊ณผ์˜ ๊ฑฐ๋ฆฌ r1๊ณผ ๋ฐฑ์Šนํ™˜์ด ๊ณ„์‚ฐํ•œ ๋ฅ˜์žฌ๋ช…๊ณผ์˜ ๊ฑฐ๋ฆฌ r2๊ฐ€ ์ฃผ์–ด์กŒ์„ ๋•Œ, ๋ฅ˜์žฌ๋ช…์ด ์žˆ์„ ์ˆ˜ ์žˆ๋Š” ์ขŒํ‘œ์˜ ์ˆ˜๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค.

 

์ž…๋ ฅ

์ฒซ์งธ ์ค„์— ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค์˜ ๊ฐœ์ˆ˜ T๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. ๊ฐ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ด๋ฃจ์–ด์ ธ ์žˆ๋‹ค.

ํ•œ ์ค„์— x1, y1, r1, x2, y2, r2๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. x1, y1, x2, y2๋Š” -10,000๋ณด๋‹ค ํฌ๊ฑฐ๋‚˜ ๊ฐ™๊ณ , 10,000๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™์€ ์ •์ˆ˜์ด๊ณ , r1, r2๋Š” 10,000๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™์€ ์ž์—ฐ์ˆ˜์ด๋‹ค.

 

์ถœ๋ ฅ

๊ฐ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋งˆ๋‹ค ๋ฅ˜์žฌ๋ช…์ด ์žˆ์„ ์ˆ˜ ์žˆ๋Š” ์œ„์น˜์˜ ์ˆ˜๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. ๋งŒ์•ฝ ๋ฅ˜์žฌ๋ช…์ด ์žˆ์„ ์ˆ˜ ์žˆ๋Š” ์œ„์น˜์˜ ๊ฐœ์ˆ˜๊ฐ€ ๋ฌดํ•œ๋Œ€์ผ ๊ฒฝ์šฐ์—๋Š” -1์„ ์ถœ๋ ฅํ•œ๋‹ค.

 

์ •๋‹ต

import sys
input = sys.stdin.readline

T = int(input())
point = [list(map(int, input().split())) for _ in range(T)]

for i in range(T):
    # ๋‘ ์  ์‚ฌ์ด์˜ ๊ฑฐ๋ฆฌ
    n = ((point[i][3] - point[i][0]) ** 2 +
         (point[i][4] - point[i][1]) ** 2) ** 0.5
    # ๊ฐ ์ ์—์„œ ์ ๊นŒ์ง€์˜ ๊ฑฐ๋ฆฌ
    k1, k2 = point[i][2], point[i][5]

    # ๋‘ ์›์ด ๊ฐ™์„ ๋•Œ
    if n == 0 and k1 == k2:
        print(-1)
    # ๋‘ ์›์ด ๊ฒน์ณ ๋‘ ์ ์—์„œ ๋งŒ๋‚  ๋•Œ
    elif abs(k2 - k1) < n < k1 + k2:
        print(2)
    # ๋‘ ์›์ด ๋‚ด์ ‘ํ•˜๊ฑฐ๋‚˜ ์™ธ์ ‘ํ•  ๋•Œ 
    elif n == k1 + k2 or n == abs(k2 - k1):
        print(1)
    # ๋‘ ์›์ด ๋งŒ๋‚˜์ง€ ์•Š์„ ๋•Œ
    else:
        print(0)

๊ฐ ์ ์—์„œ ์ ๊นŒ์ง€์˜ ๊ฑฐ๋ฆฌ๋ฅผ ์ด์šฉํ•ด ๊ฐ€๋Šฅํ•œ ์ ์˜ ์œ„์น˜์˜ ์ง‘ํ•ฉ์„ ๊ตฌํ•˜๋ฉด ์›์ด ๋œ๋‹ค.

๋‘ ์ ์ด๋ฏ€๋กœ ๋‘ ์›์ด ๋‚˜์˜ค๊ณ  ์ด๋ฅผ ์ด์šฉํ•˜์—ฌ ๋‘ ์›์ด ๋งŒ๋‚˜๋Š” ๊ฒฝ์šฐ๋ฅผ ๋”ฐ์ง„๋‹ค.

728x90

BELATED ARTICLES

more