結果

問題 No.419 直角三角形
ユーザー mura40424mura40424
提出日時 2016-12-18 14:14:15
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 331 ms / 1,000 ms
コード長 612 bytes
コンパイル時間 9,943 ms
コンパイル使用メモリ 430,016 KB
実行使用メモリ 57,916 KB
最終ジャッジ日時 2024-04-30 12:21:51
合計ジャッジ時間 18,482 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 315 ms
57,772 KB
testcase_01 AC 323 ms
57,748 KB
testcase_02 AC 326 ms
57,916 KB
testcase_03 AC 320 ms
57,776 KB
testcase_04 AC 325 ms
57,772 KB
testcase_05 AC 331 ms
57,676 KB
testcase_06 AC 325 ms
57,752 KB
testcase_07 AC 320 ms
57,656 KB
testcase_08 AC 321 ms
57,664 KB
testcase_09 AC 302 ms
57,816 KB
testcase_10 AC 314 ms
57,800 KB
testcase_11 AC 314 ms
57,684 KB
testcase_12 AC 314 ms
57,836 KB
testcase_13 AC 305 ms
57,656 KB
testcase_14 AC 321 ms
57,656 KB
testcase_15 AC 315 ms
57,692 KB
testcase_16 AC 313 ms
57,640 KB
testcase_17 AC 311 ms
57,772 KB
testcase_18 AC 308 ms
57,660 KB
testcase_19 AC 306 ms
57,792 KB
testcase_20 AC 304 ms
57,716 KB
testcase_21 AC 309 ms
57,832 KB
testcase_22 AC 308 ms
57,660 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 = java.lang.String.format("%.10f", 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