結果

問題 No.2081 Make a Test Case of GCD Subset
ユーザー 👑 箱星箱星
提出日時 2022-09-25 21:56:39
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 1,515 bytes
コンパイル時間 15,884 ms
コンパイル使用メモリ 427,388 KB
実行使用メモリ 57,480 KB
最終ジャッジ日時 2023-08-24 02:12:00
合計ジャッジ時間 26,385 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 282 ms
54,856 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 316 ms
55,212 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

fun PrintWriter.solve() {
    val size = 100000
    val isPrime = BooleanArray(size) { true }
    val primes = mutableListOf<Int>()
    for (p in 2 until size) {
        if (!isPrime[p]) continue
        primes.add(p)
        var n = p * 2
        while (n < size) {
            isPrime[n] = false
            n += p
        }
    }
    val m = nextInt()
    if (m == 0) {
        println(1)
        println(1)
        return
    }
    val s = m.toString(2).padStart(30, '0')
    var ind = 30
    val ans = mutableListOf<Int>()
    for (i in 29 downTo 0) {
        if (s[i] == '1') {
            repeat(30 - i) {
                ans.add(primes[i] * primes[ind])
                ind++
            }
        }
    }
    println(ans.size)
    println(ans.joinToString(" "))
}

fun main() {
    Thread(null, {
        val writer = PrintWriter(System.out, false)
        writer.solve()
        writer.flush()
    }, "solve", abs(1L.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