結果

問題 No.1084 積の積
ユーザー 👑 rin204rin204
提出日時 2022-07-06 07:16:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 211 ms / 2,000 ms
コード長 446 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 87,028 KB
実行使用メモリ 91,420 KB
最終ジャッジ日時 2023-08-22 22:40:39
合計ジャッジ時間 6,765 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,072 KB
testcase_01 AC 74 ms
71,168 KB
testcase_02 AC 75 ms
71,156 KB
testcase_03 AC 71 ms
71,328 KB
testcase_04 AC 211 ms
89,024 KB
testcase_05 AC 87 ms
88,152 KB
testcase_06 AC 211 ms
89,192 KB
testcase_07 AC 71 ms
71,400 KB
testcase_08 AC 73 ms
71,304 KB
testcase_09 AC 93 ms
90,164 KB
testcase_10 AC 74 ms
71,244 KB
testcase_11 AC 83 ms
76,452 KB
testcase_12 AC 118 ms
81,472 KB
testcase_13 AC 158 ms
89,424 KB
testcase_14 AC 109 ms
79,348 KB
testcase_15 AC 107 ms
79,232 KB
testcase_16 AC 172 ms
91,420 KB
testcase_17 AC 115 ms
80,836 KB
testcase_18 AC 138 ms
85,916 KB
testcase_19 AC 161 ms
89,572 KB
testcase_20 AC 100 ms
77,456 KB
testcase_21 AC 107 ms
79,352 KB
testcase_22 AC 101 ms
78,212 KB
testcase_23 AC 128 ms
83,692 KB
testcase_24 AC 122 ms
82,384 KB
testcase_25 AC 157 ms
89,292 KB
testcase_26 AC 174 ms
89,924 KB
testcase_27 AC 173 ms
89,700 KB
testcase_28 AC 173 ms
89,624 KB
testcase_29 AC 174 ms
89,720 KB
testcase_30 AC 175 ms
89,824 KB
testcase_31 AC 173 ms
89,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7

n = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
    exit()

prod = 1
prod_all = 1
ans = 1
r = 0
A.append(10 ** 10)
for l in range(n):
    while prod * A[r] < 10 ** 9:
        prod *= A[r]
        prod_all *= prod
        prod_all %= MOD
        r += 1
    ans *= prod_all
    ans %= MOD
    le = r - l
    prod //= A[l]
    prod_all *= pow(A[l], le * (MOD - 2), MOD)
    prod_all %= MOD
print(ans)
0