結果

問題 No.1237 EXP Multiple!
ユーザー FromBooskaFromBooska
提出日時 2023-09-12 15:51:43
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 801 bytes
コンパイル時間 269 ms
コンパイル使用メモリ 87,048 KB
実行使用メモリ 105,728 KB
最終ジャッジ日時 2023-09-12 15:51:48
合計ジャッジ時間 3,965 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,208 KB
testcase_01 AC 127 ms
99,380 KB
testcase_02 AC 156 ms
100,884 KB
testcase_03 AC 154 ms
100,916 KB
testcase_04 AC 123 ms
99,224 KB
testcase_05 AC 109 ms
104,788 KB
testcase_06 AC 102 ms
103,812 KB
testcase_07 AC 122 ms
105,700 KB
testcase_08 AC 109 ms
104,748 KB
testcase_09 AC 110 ms
104,600 KB
testcase_10 AC 142 ms
105,728 KB
testcase_11 AC 104 ms
103,916 KB
testcase_12 AC 109 ms
104,688 KB
testcase_13 WA -
testcase_14 AC 111 ms
104,856 KB
testcase_15 AC 111 ms
104,644 KB
testcase_16 AC 110 ms
104,560 KB
testcase_17 AC 109 ms
104,584 KB
testcase_18 AC 112 ms
104,688 KB
testcase_19 AC 136 ms
105,216 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()

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 == 0 or denominator == 1:
        print(-1)
    else:
        ans = mod%denominator
        print(ans)
        

0