結果

問題 No.113 宝探し
ユーザー バカらっくバカらっく
提出日時 2019-09-30 23:52:57
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 265 ms / 5,000 ms
コード長 530 bytes
コンパイル時間 12,452 ms
コンパイル使用メモリ 438,492 KB
実行使用メモリ 54,332 KB
最終ジャッジ日時 2024-04-28 08:31:18
合計ジャッジ時間 18,995 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 246 ms
54,176 KB
testcase_01 AC 242 ms
54,116 KB
testcase_02 AC 245 ms
54,068 KB
testcase_03 AC 250 ms
54,072 KB
testcase_04 AC 252 ms
54,116 KB
testcase_05 AC 246 ms
54,120 KB
testcase_06 AC 241 ms
54,140 KB
testcase_07 AC 247 ms
54,120 KB
testcase_08 AC 244 ms
54,020 KB
testcase_09 AC 254 ms
54,152 KB
testcase_10 AC 250 ms
54,200 KB
testcase_11 AC 255 ms
54,104 KB
testcase_12 AC 258 ms
54,304 KB
testcase_13 AC 263 ms
54,284 KB
testcase_14 AC 250 ms
54,136 KB
testcase_15 AC 256 ms
53,984 KB
testcase_16 AC 257 ms
54,088 KB
testcase_17 AC 249 ms
54,176 KB
testcase_18 AC 254 ms
54,148 KB
testcase_19 AC 265 ms
54,116 KB
testcase_20 AC 260 ms
54,060 KB
testcase_21 AC 257 ms
54,188 KB
testcase_22 AC 248 ms
54,064 KB
testcase_23 AC 250 ms
54,140 KB
testcase_24 AC 255 ms
54,332 KB
testcase_25 AC 256 ms
54,008 KB
testcase_26 AC 255 ms
54,020 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