結果

問題 No.1298 OR XOR
ユーザー rutilicusrutilicus
提出日時 2020-12-13 15:09:18
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 567 bytes
コンパイル時間 13,451 ms
コンパイル使用メモリ 430,748 KB
実行使用メモリ 54,324 KB
最終ジャッジ日時 2023-10-20 03:42:20
合計ジャッジ時間 20,591 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 286 ms
54,292 KB
testcase_01 AC 287 ms
54,280 KB
testcase_02 AC 289 ms
54,292 KB
testcase_03 AC 289 ms
54,288 KB
testcase_04 AC 289 ms
54,280 KB
testcase_05 AC 288 ms
54,288 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:23:17: warning: 'appendln(String?): 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("$a $b $n")
                ^
Main.kt:25:17: warning: 'appendln(String?): 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("-1 -1 -1")
                ^

ソースコード

diff #

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