結果

問題 No.1237 EXP Multiple!
ユーザー 👑 箱星箱星
提出日時 2020-09-25 21:37:14
言語 Kotlin
(1.9.23)
結果
RE  
実行時間 -
コード長 1,119 bytes
コンパイル時間 15,417 ms
コンパイル使用メモリ 415,924 KB
実行使用メモリ 61,424 KB
最終ジャッジ日時 2023-09-10 15:01:46
合計ジャッジ時間 26,082 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 282 ms
53,684 KB
testcase_01 AC 480 ms
60,040 KB
testcase_02 AC 479 ms
61,396 KB
testcase_03 AC 478 ms
61,392 KB
testcase_04 AC 482 ms
61,424 KB
testcase_05 AC 421 ms
59,252 KB
testcase_06 AC 462 ms
59,504 KB
testcase_07 AC 428 ms
59,528 KB
testcase_08 AC 448 ms
59,488 KB
testcase_09 AC 440 ms
61,048 KB
testcase_10 AC 445 ms
59,292 KB
testcase_11 RE -
testcase_12 AC 429 ms
59,500 KB
testcase_13 AC 439 ms
59,592 KB
testcase_14 AC 457 ms
59,300 KB
testcase_15 AC 463 ms
59,204 KB
testcase_16 AC 461 ms
59,188 KB
testcase_17 AC 468 ms
59,244 KB
testcase_18 AC 461 ms
59,464 KB
testcase_19 AC 449 ms
59,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val a = Array(n) { sc.nextInt() }
    val M = 1000000007
    if (a.contains(0)) {
        println(-1)
    } else if (a.any { it >= 4 }) {
        println(M)
    } else {
        var v = 1L
        for (i in 0 until n) {
            if (a[i] == 2) v *= 4
            else if (a[i] == 3) v *= 729
        }
        println(M % v)
    }
}

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

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    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()
    fun ready() = br.ready()
}
0