結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー 👑 箱星箱星
提出日時 2021-07-21 23:14:59
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 1,521 bytes
コンパイル時間 16,060 ms
コンパイル使用メモリ 426,112 KB
実行使用メモリ 70,820 KB
最終ジャッジ日時 2023-09-24 19:44:05
合計ジャッジ時間 37,511 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 WA -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

fun PrintWriter.solve() {
    val size = 100
    val isprime = BooleanArray(size) { true }
    for (p in 2 until size) {
        if (!isprime[p]) continue
        var i = 2
        while (p * i < size) {
            isprime[p * i] = false
            i++
        }
    }
    val plst = (2 until size).filter { isprime[it] }.toList()
    val numCases = nextInt()
    case@ for (_i in 0 until numCases) {
        val x = nextLong()
        var min = Long.MAX_VALUE
        val pl2 = mutableListOf<Int>()
        for (p in plst) {
            if (x % p == 0L) {
                pl2.add(p)
                var y = x
                var z = p.toLong()
                while (y % p == 0L) {
                    y /= p
                    z *= p
                }
                min = minOf(min, z)
            } else {
                min = minOf(min, p.toLong())
            }
        }
        min = minOf(min, pl2.take(2).let { it[0] * it[1].toLong() })
        println(x * min)
    }
}

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

// 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