結果

問題 No.1298 OR XOR
ユーザー 👑 箱星箱星
提出日時 2021-10-09 10:40:41
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 342 ms / 2,000 ms
コード長 1,217 bytes
コンパイル時間 16,801 ms
コンパイル使用メモリ 428,072 KB
実行使用メモリ 59,444 KB
最終ジャッジ日時 2023-10-01 05:54:55
合計ジャッジ時間 23,636 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 329 ms
58,948 KB
testcase_01 AC 324 ms
58,004 KB
testcase_02 AC 312 ms
56,544 KB
testcase_03 AC 326 ms
58,328 KB
testcase_04 AC 320 ms
56,520 KB
testcase_05 AC 325 ms
56,464 KB
testcase_06 AC 328 ms
58,816 KB
testcase_07 AC 329 ms
57,116 KB
testcase_08 AC 342 ms
59,444 KB
testcase_09 AC 338 ms
59,256 KB
testcase_10 AC 340 ms
58,996 KB
testcase_11 AC 329 ms
57,132 KB
testcase_12 AC 324 ms
57,060 KB
testcase_13 AC 328 ms
59,044 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter
import java.util.*
import kotlin.math.*

fun PrintWriter.solve() {
    var n = nextInt()
    val ans = arrayOf(0, 0, 0)
    val lst = listOf(1, 1, 0)
    var count = 0
    var pow = 1
    while (n > 0) {
        if (n % 2 != 0) {
            for (i in 0 until 3) {
                ans[i] += pow * lst[(count + i) % 3]
            }
            count++
        }
        n /= 2
        pow *= 2
    }
    if (ans.minOrNull()!! == 0) {
        println("-1 -1 -1")
    } else {
        println(ans.joinToString(" "))
    }
}

fun main() {
    Thread(null, {
        val writer = PrintWriter(System.out, false)
        writer.solve()
        writer.flush()
    }, "solve", 1.shl(26))
        .apply { setUncaughtExceptionHandler { _, e -> e.printStackTrace(); kotlin.system.exitProcess(1) } }
        .apply { start() }.join()
}

// region Scanner
private var st = StringTokenizer("")
private val br = System.`in`.bufferedReader()

fun next(): String {
    while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())
    return st.nextToken()
}

fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextLine() = br.readLine()
fun nextDouble() = next().toDouble()
// endregion
0