結果

問題 No.1084 積の積
ユーザー chineristACchineristAC
提出日時 2020-06-19 22:20:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 180 ms / 2,000 ms
コード長 666 bytes
コンパイル時間 256 ms
コンパイル使用メモリ 87,072 KB
実行使用メモリ 92,388 KB
最終ジャッジ日時 2023-09-16 14:38:00
合計ジャッジ時間 4,748 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,512 KB
testcase_01 AC 77 ms
71,540 KB
testcase_02 AC 71 ms
71,388 KB
testcase_03 AC 73 ms
71,344 KB
testcase_04 AC 180 ms
90,076 KB
testcase_05 AC 88 ms
88,356 KB
testcase_06 AC 175 ms
90,132 KB
testcase_07 AC 72 ms
71,512 KB
testcase_08 AC 71 ms
71,436 KB
testcase_09 AC 93 ms
90,316 KB
testcase_10 AC 72 ms
71,252 KB
testcase_11 AC 84 ms
76,760 KB
testcase_12 AC 93 ms
82,100 KB
testcase_13 AC 106 ms
90,188 KB
testcase_14 AC 92 ms
79,700 KB
testcase_15 AC 90 ms
79,796 KB
testcase_16 AC 110 ms
92,388 KB
testcase_17 AC 91 ms
81,344 KB
testcase_18 AC 101 ms
86,756 KB
testcase_19 AC 106 ms
90,392 KB
testcase_20 AC 88 ms
77,756 KB
testcase_21 AC 90 ms
79,884 KB
testcase_22 AC 90 ms
78,708 KB
testcase_23 AC 96 ms
84,220 KB
testcase_24 AC 99 ms
82,956 KB
testcase_25 AC 105 ms
90,292 KB
testcase_26 AC 110 ms
90,476 KB
testcase_27 AC 110 ms
90,544 KB
testcase_28 AC 109 ms
90,728 KB
testcase_29 AC 109 ms
90,796 KB
testcase_30 AC 109 ms
90,624 KB
testcase_31 AC 109 ms
90,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

data=[0]*(N+1)
s=0
t=1
val=A[0]
while N>s and N>t:
    test=val*A[t]
    if 10**9>test:
        val=test
        t+=1
    else:
        data[s]+=1
        data[t]+=-1
        if s!=0:
            data[s-1]-=(t-s)
            data[s]+=(t-s)
        val//=A[s]
        s+=1

while N>s:
    data[s]+=1
    data[t]+=-1
    if s!=0:
        data[s-1]-=(t-s)
        data[s]+=(t-s)
    s+=1
    

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

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


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

print(ans)
0