結果
| 問題 |
No.419 直角三角形
|
| コンテスト | |
| ユーザー |
mura40424
|
| 提出日時 | 2016-12-18 14:19:20 |
| 言語 | Kotlin (2.1.0) |
| 結果 |
AC
|
| 実行時間 | 394 ms / 1,000 ms |
| コード長 | 594 bytes |
| コンパイル時間 | 11,727 ms |
| コンパイル使用メモリ | 428,100 KB |
| 実行使用メモリ | 53,016 KB |
| 最終ジャッジ日時 | 2024-11-20 07:18:56 |
| 合計ジャッジ時間 | 21,681 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
コンパイルメッセージ
Main.kt:1:10: warning: parameter 'args' is never used
fun main(args: Array<String>) {
^
ソースコード
fun main(args: Array<String>) {
val a_b : List<Int> = readLine()!!.split(" ").map { it.toInt() }
val result = "%.10f".format(getThirdSide(a_b))
println(result)
}
fun getThirdSide(ab : List<Int>) : Double {
val a = ab.first().toDouble()
val b = ab.last().toDouble()
if (a == b) {
val c2 = Math.pow(a, 2.0) + Math.pow(b, 2.0)
return Math.sqrt(c2)
} else if (a > b) {
val c2 = Math.pow(a, 2.0) - Math.pow(b, 2.0)
return Math.sqrt(c2)
} else {
val c2 = Math.pow(b, 2.0) - Math.pow(a, 2.0)
return Math.sqrt(c2)
}
}
mura40424