結果

問題 No.1084 積の積
ユーザー hedwig100hedwig100
提出日時 2020-06-19 23:01:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 179 ms / 2,000 ms
コード長 793 bytes
コンパイル時間 265 ms
コンパイル使用メモリ 86,976 KB
実行使用メモリ 92,188 KB
最終ジャッジ日時 2023-09-16 15:13:33
合計ジャッジ時間 4,954 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,264 KB
testcase_01 AC 72 ms
71,444 KB
testcase_02 AC 71 ms
71,232 KB
testcase_03 AC 72 ms
71,320 KB
testcase_04 AC 179 ms
89,928 KB
testcase_05 AC 87 ms
88,412 KB
testcase_06 AC 174 ms
89,924 KB
testcase_07 AC 71 ms
71,108 KB
testcase_08 AC 72 ms
71,252 KB
testcase_09 AC 90 ms
90,348 KB
testcase_10 AC 71 ms
71,540 KB
testcase_11 AC 81 ms
76,496 KB
testcase_12 AC 91 ms
81,780 KB
testcase_13 AC 103 ms
89,972 KB
testcase_14 AC 87 ms
79,644 KB
testcase_15 AC 85 ms
79,868 KB
testcase_16 AC 106 ms
92,188 KB
testcase_17 AC 89 ms
80,828 KB
testcase_18 AC 96 ms
86,548 KB
testcase_19 AC 103 ms
89,936 KB
testcase_20 AC 83 ms
77,580 KB
testcase_21 AC 89 ms
79,708 KB
testcase_22 AC 86 ms
78,620 KB
testcase_23 AC 94 ms
84,068 KB
testcase_24 AC 93 ms
83,016 KB
testcase_25 AC 103 ms
90,200 KB
testcase_26 AC 111 ms
90,344 KB
testcase_27 AC 112 ms
90,676 KB
testcase_28 AC 111 ms
90,676 KB
testcase_29 AC 112 ms
90,500 KB
testcase_30 AC 111 ms
90,744 KB
testcase_31 AC 110 ms
90,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 9

def main():
    N = int(input())
    A = list(map(int,input().split()))

    if 0 in A:
        print(0)
        return

    r = 0
    now = 1
    cnt = [0] * (N + 1)
    for l in range(N):
        while r < N and now * A[r] < INF:
            now *= A[r]
            r += 1
        if l > 0:
            cnt[l - 1] -= r - l + 1
        if r > 0:
            cnt[r - 1] += 1
        if l > 1:
            cnt[l - 2] += r - l
        now //= A[l]

    for i in range(N - 1,-1,-1):
        cnt[i] += cnt[i + 1]
    for i in range(N - 1,-1,-1):
        cnt[i] += cnt[i + 1]

    ans = 1
    for i in range(N):
        ans *= pow(A[i],cnt[i],MOD)
        ans %= MOD
    print(ans)
  
if __name__ == '__main__':
    main()
0