結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー 👑 箱星箱星
提出日時 2021-07-21 23:05:32
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 1,386 bytes
コンパイル時間 16,675 ms
コンパイル使用メモリ 423,076 KB
実行使用メモリ 66,660 KB
最終ジャッジ日時 2023-09-24 19:37:23
合計ジャッジ時間 42,610 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 903 ms
66,316 KB
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 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 288 ms
52,836 KB
testcase_29 AC 293 ms
52,780 KB
testcase_30 AC 292 ms
53,052 KB
testcase_31 AC 306 ms
52,820 KB
testcase_32 AC 303 ms
52,804 KB
testcase_33 AC 291 ms
52,612 KB
testcase_34 AC 291 ms
52,716 KB
testcase_35 WA -
testcase_36 AC 293 ms
52,984 KB
testcase_37 AC 291 ms
52,836 KB
testcase_38 AC 287 ms
52,704 KB
権限があれば一括ダウンロードができます

ソースコード

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
        for (p in plst) {
            if (x % p == 0L) {
                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())
            }
        }
        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