結果

問題 No.1237 EXP Multiple!
コンテスト
ユーザー zeronosu77108
提出日時 2021-02-10 18:45:04
言語 Kotlin
(2.3.20)
コンパイル:
kotlinc _filename_ -include-runtime -d main.jar
実行:
kotlin main.jar
結果
AC  
実行時間 393 ms / 2,000 ms
コード長 575 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 8,691 ms
コンパイル使用メモリ 456,380 KB
実行使用メモリ 85,464 KB
最終ジャッジ日時 2026-03-29 22:54:43
合計ジャッジ時間 16,806 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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