結果

問題 No.1396 Giri
ユーザー zeronosu77108
提出日時 2021-02-17 16:15:57
言語 Kotlin
(2.1.0)
結果
AC  
実行時間 484 ms / 2,000 ms
コード長 640 bytes
コンパイル時間 11,930 ms
コンパイル使用メモリ 435,296 KB
実行使用メモリ 115,120 KB
最終ジャッジ日時 2024-09-14 03:05:47
合計ジャッジ時間 23,157 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

//
// Created by zeronosu77108 on 2021/02/17.
//
import kotlin.collections.*
import kotlin.math.*

@kotlin.ExperimentalStdlibApi
fun main() {
    val n = readLine()!!.toInt()

    val primes = mutableListOf<Long>()
    val sieve = Array<Long>(n+1) { it.toLong() }
    for (i in 2 .. n.toLong()) {
        if (sieve[i.toInt()] == i) primes.add(i)
        for (p in primes) {
            if (i*p > n) break
            sieve[(i*p).toInt()] = p
        }
    }

    var ans = 1L
    for (p in primes.dropLast(1)) {
        var q = p;
        while (q*p <= n) q*=p
        ans *= q % 998244353
        ans %= 998244353
    }
    println(ans)
}
0