結果

問題 No.113 宝探し
ユーザー バカらっくバカらっく
提出日時 2019-09-30 23:52:57
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 285 ms / 5,000 ms
コード長 530 bytes
コンパイル時間 14,490 ms
コンパイル使用メモリ 416,880 KB
実行使用メモリ 50,644 KB
最終ジャッジ日時 2023-08-10 15:33:18
合計ジャッジ時間 23,868 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 261 ms
50,412 KB
testcase_01 AC 261 ms
50,108 KB
testcase_02 AC 255 ms
50,124 KB
testcase_03 AC 257 ms
50,364 KB
testcase_04 AC 261 ms
50,156 KB
testcase_05 AC 261 ms
50,144 KB
testcase_06 AC 256 ms
50,108 KB
testcase_07 AC 260 ms
50,104 KB
testcase_08 AC 260 ms
50,552 KB
testcase_09 AC 261 ms
50,192 KB
testcase_10 AC 260 ms
50,188 KB
testcase_11 AC 265 ms
50,572 KB
testcase_12 AC 262 ms
50,108 KB
testcase_13 AC 260 ms
50,356 KB
testcase_14 AC 260 ms
50,172 KB
testcase_15 AC 278 ms
50,472 KB
testcase_16 AC 285 ms
50,044 KB
testcase_17 AC 257 ms
50,156 KB
testcase_18 AC 263 ms
50,644 KB
testcase_19 AC 263 ms
50,416 KB
testcase_20 AC 263 ms
50,364 KB
testcase_21 AC 262 ms
50,164 KB
testcase_22 AC 257 ms
50,148 KB
testcase_23 AC 263 ms
50,104 KB
testcase_24 AC 271 ms
50,112 KB
testcase_25 AC 266 ms
50,068 KB
testcase_26 AC 262 ms
50,076 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:3:10: warning: parameter 'arr' is never used
fun main(arr:Array<String>) {
         ^

ソースコード

diff #

import kotlin.math.max

fun main(arr:Array<String>) {
    val lastPos = readLine()!!.map { getMove(it) }.reduce { acc, unit -> Pos(acc.x + unit.x, acc.y + unit.y ) }
    val ans = Math.sqrt(Math.pow(lastPos.x.toDouble(), 2.toDouble()) + Math.pow(lastPos.y.toDouble(), 2.toDouble()))
    println(ans)
}

fun getMove(dir:Char):Pos {
    val tmp = when {
        dir == 'E' -> Pos(1, 0)
        dir == 'W' -> Pos(-1, 0)
        dir == 'N' -> Pos(0, 1)
        else -> Pos(0, -1)
    }
    return tmp
}
class Pos(var x:Int, var y:Int)
0