結果

問題 No.1084 積の積
ユーザー tktk_snsntktk_snsn
提出日時 2020-06-19 22:27:50
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 311 ms / 2,000 ms
コード長 524 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 10,796 KB
実行使用メモリ 31,160 KB
最終ジャッジ日時 2023-09-16 14:44:34
合計ジャッジ時間 5,920 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,120 KB
testcase_01 AC 16 ms
8,184 KB
testcase_02 AC 16 ms
8,176 KB
testcase_03 AC 16 ms
8,128 KB
testcase_04 AC 311 ms
31,160 KB
testcase_05 AC 267 ms
31,124 KB
testcase_06 AC 310 ms
31,128 KB
testcase_07 AC 15 ms
8,104 KB
testcase_08 AC 15 ms
8,036 KB
testcase_09 AC 308 ms
26,896 KB
testcase_10 AC 15 ms
8,112 KB
testcase_11 AC 22 ms
8,644 KB
testcase_12 AC 100 ms
14,808 KB
testcase_13 AC 193 ms
22,296 KB
testcase_14 AC 79 ms
13,312 KB
testcase_15 AC 74 ms
12,756 KB
testcase_16 AC 229 ms
24,384 KB
testcase_17 AC 91 ms
14,132 KB
testcase_18 AC 151 ms
18,640 KB
testcase_19 AC 201 ms
22,416 KB
testcase_20 AC 56 ms
11,084 KB
testcase_21 AC 81 ms
13,264 KB
testcase_22 AC 65 ms
11,940 KB
testcase_23 AC 123 ms
16,456 KB
testcase_24 AC 115 ms
15,688 KB
testcase_25 AC 197 ms
22,368 KB
testcase_26 AC 245 ms
23,784 KB
testcase_27 AC 245 ms
23,688 KB
testcase_28 AC 240 ms
23,816 KB
testcase_29 AC 238 ms
23,832 KB
testcase_30 AC 248 ms
23,516 KB
testcase_31 AC 247 ms
23,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import accumulate
mod = 10 ** 9 + 7
N = int(input())
A = list(map(int, input().split()))

use = [0] * (N + 5)
lim = 10 ** 9

l = 0
memo = 1
tmp = []
for r, a in enumerate(A):
    memo *= a
    while l < r and memo >= lim:
        memo //= A[l]
        l += 1
    use[l] += 1
    use[r + 1] -= 1
    tmp.append((r + 1, r - l + 1))

use = list(accumulate(use))
for x, y in tmp:
    use[x] -= y
use = list(accumulate(use))[:N]

ans = 1
for a, c in zip(A, use):
    ans *= pow(a, c, mod)
    ans %= mod
print(ans)
0