結果

問題 No.1298 OR XOR
コンテスト
ユーザー rutilicus
提出日時 2020-12-13 15:11:58
言語 Kotlin
(2.3.20)
コンパイル:
kotlinc _filename_ -include-runtime -d main.jar
実行:
kotlin main.jar
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 571 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 8,074 ms
コンパイル使用メモリ 414,772 KB
最終ジャッジ日時 2026-04-08 12:12:04
合計ジャッジ時間 8,677 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
Main.kt:23:17: error: 'fun StringBuilder.appendln(value: String?): 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("$a $b $n")
                ^^^^^^^^
Main.kt:25:17: error: 'fun StringBuilder.appendln(value: String?): 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("-1 -1 -1")
                ^^^^^^^^

ソースコード

diff #
raw source code

fun main() {
    val builder = StringBuilder()

    val n = readInputLine().toInt()

    var a = 0
    var b = 0

    var addA = true

    for (i in 0 until 30) {
        if ((n shr i) and 1 == 1) {
            if (addA) {
                a = a or (1 shl i)
            } else {
                b = b or (1 shl i)
            }
            addA = !addA
        }
    }

    if (b != 0) {
        builder.appendln("$a $b $n")
    } else {
        builder.appendln("-1 -1 -1")
    }

    print(builder.toString())
}

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