結果

問題 No.1084 積の積
ユーザー rlangevinrlangevin
提出日時 2023-11-07 12:15:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 197 ms / 2,000 ms
コード長 439 bytes
コンパイル時間 344 ms
コンパイル使用メモリ 81,880 KB
実行使用メモリ 90,816 KB
最終ジャッジ日時 2023-11-07 12:15:51
合計ジャッジ時間 6,604 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,696 KB
testcase_01 AC 41 ms
53,696 KB
testcase_02 AC 40 ms
53,696 KB
testcase_03 AC 41 ms
53,696 KB
testcase_04 AC 112 ms
83,360 KB
testcase_05 AC 55 ms
76,392 KB
testcase_06 AC 107 ms
83,228 KB
testcase_07 AC 37 ms
53,680 KB
testcase_08 AC 42 ms
53,696 KB
testcase_09 AC 63 ms
82,460 KB
testcase_10 AC 37 ms
53,680 KB
testcase_11 AC 57 ms
66,668 KB
testcase_12 AC 111 ms
81,260 KB
testcase_13 AC 165 ms
88,840 KB
testcase_14 AC 100 ms
79,104 KB
testcase_15 AC 97 ms
79,016 KB
testcase_16 AC 178 ms
90,816 KB
testcase_17 AC 105 ms
80,468 KB
testcase_18 AC 141 ms
85,516 KB
testcase_19 AC 162 ms
88,864 KB
testcase_20 AC 79 ms
74,800 KB
testcase_21 AC 98 ms
79,120 KB
testcase_22 AC 89 ms
77,976 KB
testcase_23 AC 123 ms
83,292 KB
testcase_24 AC 118 ms
81,904 KB
testcase_25 AC 162 ms
88,840 KB
testcase_26 AC 196 ms
89,328 KB
testcase_27 AC 188 ms
89,064 KB
testcase_28 AC 196 ms
89,328 KB
testcase_29 AC 197 ms
89,064 KB
testcase_30 AC 193 ms
89,064 KB
testcase_31 AC 195 ms
89,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
    exit()
mod = 10 ** 9 + 7

from collections import *
Q = deque()
val, now = 1, 1
inf = 10 ** 9
ans = 1
for i in range(N - 1, -1, -1):
    Q.appendleft(A[i])
    now *= A[i]
    val *= pow(A[i], len(Q), mod)
    val %= mod
    while now >= inf:
        a = Q.pop()
        val *= pow(now, mod-2, mod)
        now //= a
    ans *= val
    ans %= mod

print(ans)
0