結果

問題 No.1298 OR XOR
ユーザー 👑 箱
提出日時 2020-11-27 21:29:25
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 324 ms / 2,000 ms
コード長 1,084 bytes
コンパイル時間 20,555 ms
コンパイル使用メモリ 425,564 KB
実行使用メモリ 57,112 KB
最終ジャッジ日時 2023-10-01 04:47:13
合計ジャッジ時間 22,805 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 315 ms
56,704 KB
testcase_01 AC 316 ms
55,936 KB
testcase_02 AC 308 ms
56,076 KB
testcase_03 AC 309 ms
56,108 KB
testcase_04 AC 312 ms
56,148 KB
testcase_05 AC 307 ms
55,964 KB
testcase_06 AC 322 ms
57,012 KB
testcase_07 AC 317 ms
56,900 KB
testcase_08 AC 315 ms
57,112 KB
testcase_09 AC 317 ms
56,872 KB
testcase_10 AC 320 ms
56,980 KB
testcase_11 AC 321 ms
56,852 KB
testcase_12 AC 324 ms
57,100 KB
testcase_13 AC 313 ms
56,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.InputStream
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve() = with(FastScanner(System.`in`)) {
    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.min() == 0) {
        println("-1 -1 -1")
    } else {
        println(ans.joinToString(" "))
    }
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve()
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = s.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()
}
0