結果

問題 No.419 直角三角形
ユーザー mura40424mura40424
提出日時 2016-12-18 14:19:20
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 397 ms / 1,000 ms
コード長 594 bytes
コンパイル時間 13,288 ms
コンパイル使用メモリ 441,084 KB
実行使用メモリ 57,904 KB
最終ジャッジ日時 2024-04-30 12:22:37
合計ジャッジ時間 22,303 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 392 ms
57,756 KB
testcase_01 AC 379 ms
57,648 KB
testcase_02 AC 377 ms
57,788 KB
testcase_03 AC 381 ms
57,656 KB
testcase_04 AC 388 ms
57,656 KB
testcase_05 AC 386 ms
57,664 KB
testcase_06 AC 383 ms
57,652 KB
testcase_07 AC 382 ms
57,656 KB
testcase_08 AC 397 ms
57,780 KB
testcase_09 AC 385 ms
57,696 KB
testcase_10 AC 384 ms
57,780 KB
testcase_11 AC 378 ms
57,664 KB
testcase_12 AC 373 ms
57,748 KB
testcase_13 AC 377 ms
57,700 KB
testcase_14 AC 382 ms
57,668 KB
testcase_15 AC 392 ms
57,772 KB
testcase_16 AC 379 ms
57,780 KB
testcase_17 AC 377 ms
57,828 KB
testcase_18 AC 383 ms
57,708 KB
testcase_19 AC 387 ms
57,904 KB
testcase_20 AC 378 ms
57,640 KB
testcase_21 AC 371 ms
57,796 KB
testcase_22 AC 377 ms
57,784 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:1:10: warning: parameter 'args' is never used
fun main(args: Array<String>) {
         ^

ソースコード

diff #

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)
    }
}
0