Bibi's DevLog ๐Ÿค“๐ŸŽ

[๋ฐฑ์ค€ 7510] ๊ณ ๊ธ‰ ์ˆ˜ํ•™ (Swift) ๋ณธ๋ฌธ

ํ”„๋กœ๊ทธ๋ž˜๋ฐ/์•Œ๊ณ ๋ฆฌ์ฆ˜ ํ’€์ด Swift

[๋ฐฑ์ค€ 7510] ๊ณ ๊ธ‰ ์ˆ˜ํ•™ (Swift)

๋น„๋น„ bibi 2022. 11. 29. 15:10

7510๋ฒˆ: ๊ณ ๊ธ‰ ์ˆ˜ํ•™

  • ํ”ผํƒ€๊ณ ๋ผ์Šค ์ •๋ฆฌ : ๋น—๋ณ€์˜ ๊ธธ์ด์˜ ์ œ๊ณฑ์€ ๋‚˜๋จธ์ง€ ๋‘ ๋ณ€์˜ ๊ธธ์ด๋ฅผ ์ œ๊ณฑํ•œ ๋’ค ๋”ํ•œ ๊ฒƒ๊ณผ ๊ฐ™๋‹ค.
  • ์„ธ ๋ณ€์˜ ๊ธธ์ด a, b, c ๊ฐ€ ์ฃผ์–ด์งˆ ๋•Œ (c๊ฐ€ ๋น—๋ณ€) c์ œ๊ณฑ = a์ œ๊ณฑ + b์ œ๊ณฑ.
    • c๋Š” ๋น—๋ณ€์ด๋ฏ€๋กœ ์ฃผ์–ด์ง„ ์„ธ ๋ณ€ ์ค‘ ๊ฐ€์žฅ ๊ธธ์ด๊ฐ€ ๊ธธ๋‹ค.
  • ์ถœ๋ ฅ ํ˜•์‹์— ์œ ์˜ํ•˜์ž (์‹œ๋‚˜๋ฆฌ์˜ค ์‚ฌ์ด์— ๊ณต๋ฐฑ์„ ์ถœ๋ ฅํ•ด์•ผ ํ•จ)

ํ’€์ด

import Foundation
let count = Int(readLine()!)!
(1...count).forEach { num in
    var arr = readLine()!.split(separator: " ").map { Double($0)! }
    arr = arr.sorted()
    print("Scenario #\(num):")
    if pow(arr[2], 2) == pow(arr[0], 2) + pow(arr[1], 2) {
        print("yes")
    } else {
        print("no")
    }
    if num != count {
        print("")
    }
}