結果

問題 No.1237 EXP Multiple!
ユーザー zeronosu77108
提出日時 2021-02-10 18:45:04
言語 Kotlin
(2.1.0)
結果
AC  
実行時間 531 ms / 2,000 ms
コード長 575 bytes
コンパイル時間 13,681 ms
コンパイル使用メモリ 439,304 KB
実行使用メモリ 81,288 KB
最終ジャッジ日時 2024-07-08 05:27:33
合計ジャッジ時間 20,696 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 19
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:3:9: warning: variable 'n' is never used
    val n = readLine()!!.toInt()
        ^

ソースコード

diff #

fun main() {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toLong() }

    if (a.any { it >= 4 }) {
        println(1_000_000_007)
        return
    }

    if (a.any { it == 0L }) {
        println(-1)
        return
    }

    var pi = 1L
    for (ai in a) {
        val k = (1..ai).fold(1) { acc, x -> (acc * x).toInt() }
        for (i in 0 until k) {
            pi *= ai
            if (pi > 1_000_000_007) {
                println(1_000_000_007)
                return
            }

        }
    }

    println(1_000_000_007 % pi)
}
0