結果

問題 No.1084 積の積
ユーザー neterukunneterukun
提出日時 2020-06-20 12:50:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 931 bytes
コンパイル時間 1,185 ms
コンパイル使用メモリ 86,504 KB
実行使用メモリ 97,720 KB
最終ジャッジ日時 2023-09-16 17:19:34
合計ジャッジ時間 5,991 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,284 KB
testcase_01 AC 68 ms
71,200 KB
testcase_02 AC 68 ms
71,036 KB
testcase_03 AC 68 ms
70,856 KB
testcase_04 AC 211 ms
95,316 KB
testcase_05 AC 93 ms
94,972 KB
testcase_06 AC 207 ms
95,292 KB
testcase_07 AC 68 ms
71,164 KB
testcase_08 AC 68 ms
71,084 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 80 ms
76,544 KB
testcase_12 AC 118 ms
83,544 KB
testcase_13 AC 161 ms
94,792 KB
testcase_14 AC 105 ms
80,392 KB
testcase_15 AC 102 ms
80,528 KB
testcase_16 AC 173 ms
97,720 KB
testcase_17 AC 114 ms
82,532 KB
testcase_18 AC 140 ms
89,852 KB
testcase_19 AC 162 ms
94,840 KB
testcase_20 AC 94 ms
77,636 KB
testcase_21 AC 110 ms
80,472 KB
testcase_22 AC 105 ms
78,868 KB
testcase_23 AC 132 ms
86,480 KB
testcase_24 AC 125 ms
85,032 KB
testcase_25 AC 165 ms
94,912 KB
testcase_26 AC 181 ms
96,200 KB
testcase_27 AC 180 ms
96,012 KB
testcase_28 AC 181 ms
96,236 KB
testcase_29 AC 180 ms
96,104 KB
testcase_30 AC 183 ms
96,312 KB
testcase_31 AC 184 ms
96,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int, input().split()))
LIMIT = 10 ** 9
MOD = 10 ** 9 + 7

dist = []
tmp = []
for i in range(n + 1):
    if i == n or a[i] == 0:
        dist.append(tmp)
        tmp = []
    else:
        tmp.append(a[i])
def solve(a, n):
    # 区間[l, r)を考えつつつ、lとrを尺取りする
    r = 0
    ru_val = 1
    ptn_val = 1
    ans = 1
    for l in range(n):
        if l > 0:
            ru_val //= a[l - 1]
            ptn_val *= pow(pow(a[l - 1], (r - (l - 1)), MOD), MOD - 2, MOD)
            ptn_val %= MOD
        while r < n and  ru_val * a[r] < LIMIT:
            ru_val *= a[r]
            ptn_val *= ru_val
            ptn_val %= MOD
            r += 1
        ans *= ptn_val
        ans %= MOD
    return ans
  
ans = 1
flag = False
for li in dist:
    if not li:
        continue
    flag = True
    ans *= solve(li, len(li))
    ans %= MOD
if not flag:
    print(0)
else:
    print(ans)
0