結果

問題 No.1237 EXP Multiple!
コンテスト
ユーザー hiraku
提出日時 2020-10-27 09:55:42
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 84 ms / 2,000 ms
+ 856µs
コード長 396 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 70 ms
コンパイル使用メモリ 14,848 KB
実行使用メモリ 32,852 KB
最終ジャッジ日時 2026-10-13 11:46:16
合計ジャッジ時間 3,932 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

# No.1237 EXP Multiple!
# https://yukicoder.me/problems/no/1237

from math import factorial

def f(x):
  return x ** factorial(x)

n = int(input())
A = list(map(int, input().split()))

MOD = 10 ** 9 + 7

if any(a == 0 for a in A):
  print(-1)
  exit()

if any(a > 9 for a in A):
  print(MOD)
  exit()

ans = 1
for a in A:
  if ans >= MOD:
    print(MOD)
    exit()
  ans *= f(a)

print(MOD % ans)
0