結果

問題 No.1084 積の積
ユーザー titiatitia
提出日時 2020-06-19 22:22:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 359 ms / 2,000 ms
コード長 618 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 10,964 KB
実行使用メモリ 19,020 KB
最終ジャッジ日時 2023-09-16 14:39:31
合計ジャッジ時間 6,067 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,764 KB
testcase_01 AC 15 ms
7,748 KB
testcase_02 AC 16 ms
7,784 KB
testcase_03 AC 16 ms
7,816 KB
testcase_04 AC 359 ms
14,176 KB
testcase_05 AC 32 ms
9,944 KB
testcase_06 AC 353 ms
14,180 KB
testcase_07 AC 15 ms
8,108 KB
testcase_08 AC 16 ms
7,776 KB
testcase_09 AC 45 ms
18,376 KB
testcase_10 AC 15 ms
8,196 KB
testcase_11 AC 24 ms
8,520 KB
testcase_12 AC 111 ms
12,544 KB
testcase_13 AC 217 ms
17,688 KB
testcase_14 AC 88 ms
11,864 KB
testcase_15 AC 87 ms
11,616 KB
testcase_16 AC 260 ms
19,020 KB
testcase_17 AC 103 ms
12,836 KB
testcase_18 AC 173 ms
15,192 KB
testcase_19 AC 228 ms
17,608 KB
testcase_20 AC 65 ms
10,500 KB
testcase_21 AC 91 ms
11,600 KB
testcase_22 AC 72 ms
11,468 KB
testcase_23 AC 137 ms
13,928 KB
testcase_24 AC 127 ms
13,216 KB
testcase_25 AC 217 ms
17,672 KB
testcase_26 AC 267 ms
18,644 KB
testcase_27 AC 262 ms
18,668 KB
testcase_28 AC 260 ms
18,672 KB
testcase_29 AC 267 ms
18,652 KB
testcase_30 AC 272 ms
18,676 KB
testcase_31 AC 266 ms
18,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

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

if 0 in A:
    print(0)
    sys.exit()
    
j=0
NOW=1
R=[0]*N
for i in range(N):
    #print(i,j,NOW)
    while j<N and NOW*A[j]<10**9:
        NOW*=A[j]
        j+=1
    R[i]=j
    NOW//=A[i]

ANS=[0]*(N+2)

for i in range(N):
    ANS[R[i]-1]+=1
    ANS[i-1]-=1

#print(ANS)

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

#print(ANS)

for i in range(N):
    ANS[i-1]-=R[i]-i

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

#print(ANS)

X=1
for i in range(N):
    X=X*pow(A[i],ANS[i],mod)%mod
print(X)


    
    
0