結果

問題 No.1237 EXP Multiple!
ユーザー FromBooskaFromBooska
提出日時 2023-09-12 15:54:44
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 821 bytes
コンパイル時間 407 ms
コンパイル使用メモリ 86,964 KB
実行使用メモリ 104,924 KB
最終ジャッジ日時 2023-09-12 15:54:48
合計ジャッジ時間 4,063 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,220 KB
testcase_01 AC 124 ms
99,332 KB
testcase_02 AC 161 ms
100,832 KB
testcase_03 AC 152 ms
100,796 KB
testcase_04 AC 120 ms
99,240 KB
testcase_05 AC 101 ms
103,776 KB
testcase_06 AC 101 ms
103,832 KB
testcase_07 AC 105 ms
104,352 KB
testcase_08 AC 107 ms
104,604 KB
testcase_09 AC 102 ms
103,808 KB
testcase_10 AC 109 ms
104,452 KB
testcase_11 AC 102 ms
103,760 KB
testcase_12 AC 116 ms
104,596 KB
testcase_13 WA -
testcase_14 AC 107 ms
104,596 KB
testcase_15 AC 106 ms
104,792 KB
testcase_16 AC 104 ms
104,832 KB
testcase_17 AC 106 ms
104,900 KB
testcase_18 AC 107 ms
104,924 KB
testcase_19 AC 103 ms
103,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# オイラーの小定理とかではない
# 問題文よく読むと、mod 10**9+7を計算式で割る、いつもの逆
# ということは計算式がmodを超えたら答えは常にmod
# 実験するとすぐわかるがaが4以上でmodを超える

from math import factorial
mod = 10**9+7

N = int(input())
A = list(map(int, input().split()))
A.sort()

if A[0] == 0:
    print(-1)
    exit()

denominator = 1
ans_flag = False
for i in range(N):
    if A[i]<=3:
        calc = pow(A[i], factorial(A[i]))
        denominator *= calc
        if denominator > mod:
            ans_flag = True
            break
    else:
        ans_flag = True
        break
if ans_flag == True:
    print(mod)
else:
    if denominator == 1:
        print(-1)
    else:
        ans = mod%denominator
        print(ans)
        

0