結果

問題 No.1084 積の積
ユーザー convexineqconvexineq
提出日時 2020-06-19 22:17:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 193 ms / 2,000 ms
コード長 633 bytes
コンパイル時間 258 ms
コンパイル使用メモリ 87,056 KB
実行使用メモリ 96,920 KB
最終ジャッジ日時 2023-09-16 14:36:13
合計ジャッジ時間 5,032 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,236 KB
testcase_01 AC 73 ms
71,240 KB
testcase_02 AC 76 ms
71,508 KB
testcase_03 AC 70 ms
71,236 KB
testcase_04 AC 193 ms
93,736 KB
testcase_05 AC 90 ms
91,132 KB
testcase_06 AC 189 ms
93,608 KB
testcase_07 AC 70 ms
71,356 KB
testcase_08 AC 70 ms
71,312 KB
testcase_09 AC 95 ms
93,652 KB
testcase_10 AC 71 ms
71,488 KB
testcase_11 AC 83 ms
76,348 KB
testcase_12 AC 97 ms
84,060 KB
testcase_13 AC 114 ms
94,284 KB
testcase_14 AC 92 ms
81,332 KB
testcase_15 AC 91 ms
81,128 KB
testcase_16 AC 120 ms
96,920 KB
testcase_17 AC 95 ms
83,016 KB
testcase_18 AC 105 ms
89,644 KB
testcase_19 AC 114 ms
94,340 KB
testcase_20 AC 89 ms
78,612 KB
testcase_21 AC 92 ms
81,224 KB
testcase_22 AC 89 ms
79,736 KB
testcase_23 AC 98 ms
86,456 KB
testcase_24 AC 99 ms
85,156 KB
testcase_25 AC 112 ms
94,232 KB
testcase_26 AC 126 ms
94,496 KB
testcase_27 AC 125 ms
94,476 KB
testcase_28 AC 125 ms
94,400 KB
testcase_29 AC 125 ms
94,476 KB
testcase_30 AC 124 ms
94,700 KB
testcase_31 AC 127 ms
94,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,*a = map(int,read().split())

if 0 in a:
    print(0)
    exit()

MOD = 10**9+7

coeff = [0]*(n+1)
const = [0]*(n+1)

res = 1
r = 0
for l in range(n):
    while r < n and res*a[r] < 10**9:
        res *= a[r]
        r += 1
    res //= a[l]
    coeff[l] -= 1
    coeff[r] += 1
    const[l] += r
    const[r] -= r

for i in range(n):
    coeff[i+1] += coeff[i]
    const[i+1] += const[i]

ans = 1
for idx,(i,j,k) in enumerate(zip(a,coeff,const)):
    r = j*(idx)+k
    #print(r)
    ans *= pow(i,r,MOD)
    ans %= MOD

print(ans)




0