結果

問題 No.1237 EXP Multiple!
ユーザー Shirotsume
提出日時 2023-02-17 19:58:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 559 bytes
コンパイル時間 717 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 101,292 KB
最終ジャッジ日時 2024-07-19 11:22:32
合計ジャッジ時間 2,724 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import deque, Counter
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())

n = ii()

a = li()
a.sort()
ans = 1
p = [0, 1, 4, 729]
for i in range(n):
    if a[i] >= 4:
        print(10 ** 9 + 7)
        exit()
    else:
        ans *= p[a[i]]
        if ans == 0:
            print(-1)
            exit()
        if ans > 10 ** 9 + 7:
            print(10 ** 9 + 7)
            exit()

if ans == 0:
    print(-1)
else:
    print((10 ** 9 + 7) % ans)
0