結果

問題 No.48 ロボットの操縦
コンテスト
ユーザー rutilicus
提出日時 2020-08-30 22:00:46
言語 Kotlin
(2.3.10)
コンパイル:
kotlinc _filename_ -include-runtime -d main.jar
実行:
kotlin main.jar
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 612 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 8,655 ms
コンパイル使用メモリ 390,908 KB
最終ジャッジ日時 2026-02-27 03:55:44
合計ジャッジ時間 9,423 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
Main.kt:11:17: error: 'fun StringBuilder.appendln(value: Int): 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: error: 'fun StringBuilder.appendln(value: Int): 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: error: 'fun StringBuilder.appendln(value: Int): 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: error: 'fun StringBuilder.appendln(value: Int): 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 #
raw source code

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