結果

問題 No.1084 積の積
ユーザー ayaoniayaoni
提出日時 2020-11-26 14:56:26
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 822 bytes
コンパイル時間 356 ms
コンパイル使用メモリ 87,188 KB
実行使用メモリ 104,456 KB
最終ジャッジ日時 2023-10-01 03:21:56
合計ジャッジ時間 6,368 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,520 KB
testcase_01 AC 76 ms
71,340 KB
testcase_02 AC 75 ms
71,592 KB
testcase_03 AC 72 ms
71,484 KB
testcase_04 AC 196 ms
104,456 KB
testcase_05 RE -
testcase_06 AC 191 ms
104,388 KB
testcase_07 RE -
testcase_08 AC 72 ms
71,308 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 83 ms
76,916 KB
testcase_12 AC 95 ms
86,244 KB
testcase_13 AC 111 ms
96,972 KB
testcase_14 AC 93 ms
82,356 KB
testcase_15 AC 92 ms
82,188 KB
testcase_16 AC 116 ms
98,824 KB
testcase_17 AC 95 ms
84,744 KB
testcase_18 AC 104 ms
94,876 KB
testcase_19 AC 113 ms
96,776 KB
testcase_20 AC 86 ms
78,460 KB
testcase_21 AC 88 ms
82,160 KB
testcase_22 AC 86 ms
80,012 KB
testcase_23 AC 98 ms
90,036 KB
testcase_24 AC 97 ms
88,088 KB
testcase_25 AC 111 ms
96,944 KB
testcase_26 AC 120 ms
103,404 KB
testcase_27 AC 119 ms
103,276 KB
testcase_28 AC 119 ms
103,316 KB
testcase_29 AC 120 ms
103,528 KB
testcase_30 AC 121 ms
103,388 KB
testcase_31 AC 121 ms
103,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from itertools import accumulate
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))


N = I()
A = LI()
mod = 10**9+7

count = [0]*(N+2)
a = A[0]  # 区間[l,r)の積
l,r = 0,1
while r <= N:
    if a < 10**9:
        if r <= N-1:
            a *= A[r]
            r += 1
        else:
            count[l] += r-l
            count[l+1] -= r-l+1
            count[r+1] += 1
            if l < r:
                a //= A[l]
                l += 1
            else:
                break
    else:
        count[l] += r-l-1
        count[l+1] -= r-l
        count[r] += 1
        a //= A[l]
        l += 1

count = list(accumulate(list(accumulate(count))))
ans = 1
for i in range(N):
    ans *= pow(A[i],count[i],mod)
    ans %= mod

print(ans)
0