์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ/BOJ_Python

[BOJ/Step9] 4153 : ์ง๊ฐ์‚ผ๊ฐํ˜• (Python)

NaNaRin๐Ÿ™ƒ 2021. 2. 15. 18:49

www.acmicpc.net/problem/4153

 

4153๋ฒˆ: ์ง๊ฐ์‚ผ๊ฐํ˜•

์ž…๋ ฅ์€ ์—ฌ๋Ÿฌ๊ฐœ์˜ ํ…Œ์ŠคํŠธ์ผ€์ด์Šค๋กœ ์ฃผ์–ด์ง€๋ฉฐ ๋งˆ์ง€๋ง‰์ค„์—๋Š” 0 0 0์ด ์ž…๋ ฅ๋œ๋‹ค. ๊ฐ ํ…Œ์ŠคํŠธ์ผ€์ด์Šค๋Š” ๋ชจ๋‘ 30,000๋ณด๋‹ค ์ž‘์€ ์–‘์˜ ์ •์ˆ˜๋กœ ์ฃผ์–ด์ง€๋ฉฐ, ๊ฐ ์ž…๋ ฅ์€ ๋ณ€์˜ ๊ธธ์ด๋ฅผ ์˜๋ฏธํ•œ๋‹ค.

www.acmicpc.net


์ง๊ฐ์‚ผ๊ฐํ˜•์€ ๊ฐ€์žฅ ๊ธด ๋ณ€์˜ ์ œ๊ณฑ์ด ๋‚˜๋จธ์ง€ ๋‘ ๋ณ€์˜ ์ œ๊ณฑ์˜ ํ•ฉ๊ณผ ๊ฐ™๋‹ค

1. ์ •์ˆ˜ ์„ธ๊ฐœ๋ฅผ ๋ฆฌ์ŠคํŠธ a์— ์ž…๋ ฅ๋ฐ›๊ณ  ์…‹ ๋ชจ๋‘ 0์ผ๋•Œ ๋ฌดํ•œ๋ฃจํ”„๋ฅผ ํƒˆ์ถœ

2. a๋ฅผ ์ •๋ ฌ

3. a[2]์˜ ์ œ๊ณฑ์ด a[0], a[1] ๋‘ ๋ณ€์˜ ์ œ๊ณฑ์˜ ํ•ฉ๊ณผ ๊ฐ™์œผ๋ฉด right์„, ๋‹ค๋ฅด๋ฉด wrong์„ ์ถœ๋ ฅ์‹œํ‚จ๋‹ค.

# 4153.py

while True:
    a = list(map(int, input().split()))
    if a[0] == 0 and a[1] == 0 and a[2] == 0:
        break

    a = sorted(a)
    if a[0] ** 2 + a[1] ** 2 == a[2] ** 2:
        print('right')
    else:
        print('wrong')