結果

問題 No.48 ロボットの操縦
ユーザー rutilicusrutilicus
提出日時 2020-08-30 22:00:46
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 289 ms / 5,000 ms
コード長 612 bytes
コンパイル時間 10,426 ms
コンパイル使用メモリ 428,144 KB
実行使用メモリ 56,936 KB
最終ジャッジ日時 2024-04-27 13:26:54
合計ジャッジ時間 18,730 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 283 ms
56,780 KB
testcase_01 AC 280 ms
56,744 KB
testcase_02 AC 289 ms
56,860 KB
testcase_03 AC 288 ms
56,780 KB
testcase_04 AC 281 ms
56,868 KB
testcase_05 AC 279 ms
56,816 KB
testcase_06 AC 282 ms
56,872 KB
testcase_07 AC 284 ms
56,704 KB
testcase_08 AC 277 ms
56,764 KB
testcase_09 AC 281 ms
56,784 KB
testcase_10 AC 276 ms
56,864 KB
testcase_11 AC 281 ms
56,812 KB
testcase_12 AC 279 ms
56,936 KB
testcase_13 AC 284 ms
56,668 KB
testcase_14 AC 277 ms
56,824 KB
testcase_15 AC 273 ms
56,840 KB
testcase_16 AC 283 ms
56,704 KB
testcase_17 AC 288 ms
56,832 KB
testcase_18 AC 279 ms
56,672 KB
testcase_19 AC 284 ms
56,848 KB
testcase_20 AC 280 ms
56,880 KB
testcase_21 AC 278 ms
56,768 KB
testcase_22 AC 274 ms
56,776 KB
testcase_23 AC 278 ms
56,712 KB
testcase_24 AC 275 ms
56,736 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:11:17: warning: 'appendln(Int): kotlin.text.StringBuilder /* = java.lang.StringBuilder */' is deprecated. Use appendLine instead. Note that the new method always appends the line feed character '\n' regardless of the system line separator.
        builder.appendln(0)
                ^
Main.kt:13:17: warning: 'appendln(Int): kotlin.text.StringBuilder /* = java.lang.StringBuilder */' is deprecated. Use appendLine instead. Note that the new method always appends the line feed character '\n' regardless of the system line separator.
        builder.appendln((abs(y) + l - 1) / l + if (y < 0) 2 else 0)
                ^
Main.kt:15:17: warning: 'appendln(Int): kotlin.text.StringBuilder /* = java.lang.StringBuilder */' is deprecated. Use appendLine instead. Note that the new method always appends the line feed character '\n' regardless of the system line separator.
        builder.appendln((abs(x) + l - 1) / l + 1)
                ^
Main.kt:17:17: warning: 'appendln(Int): kotlin.text.StringBuilder /* = java.lang.StringBuilder */' is deprecated. Use appendLine instead. Note that the new method always appends the line feed character '\n' regardless of the system line separator.
        builder.appendln((abs(y) + l - 1) / l + (abs(x) + l - 1) / l + 1 + if (y < 0) 1 else 0)
                ^

ソースコード

diff #

import kotlin.math.abs

fun main() {
    val builder = StringBuilder()

    val x = readInputLine().toInt()
    val y = readInputLine().toInt()
    val l = readInputLine().toInt()

    if (x == 0 && y == 0) {
        builder.appendln(0)
    } else if (x == 0) {
        builder.appendln((abs(y) + l - 1) / l + if (y < 0) 2 else 0)
    } else if (y == 0) {
        builder.appendln((abs(x) + l - 1) / l + 1)
    } else {
        builder.appendln((abs(y) + l - 1) / l + (abs(x) + l - 1) / l + 1 + if (y < 0) 1 else 0)
    }

    print(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}
0