結果

問題 No.1084 積の積
ユーザー tanon710tanon710
提出日時 2020-06-19 22:36:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 186 ms / 2,000 ms
コード長 711 bytes
コンパイル時間 263 ms
コンパイル使用メモリ 87,220 KB
実行使用メモリ 94,040 KB
最終ジャッジ日時 2023-09-16 14:51:01
合計ジャッジ時間 5,037 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,284 KB
testcase_01 AC 70 ms
71,504 KB
testcase_02 AC 70 ms
71,320 KB
testcase_03 AC 71 ms
71,436 KB
testcase_04 AC 186 ms
91,864 KB
testcase_05 AC 83 ms
88,368 KB
testcase_06 AC 186 ms
91,664 KB
testcase_07 AC 69 ms
71,320 KB
testcase_08 AC 70 ms
71,376 KB
testcase_09 AC 92 ms
90,528 KB
testcase_10 AC 67 ms
71,288 KB
testcase_11 AC 86 ms
76,840 KB
testcase_12 AC 96 ms
82,688 KB
testcase_13 AC 114 ms
91,828 KB
testcase_14 AC 93 ms
80,444 KB
testcase_15 AC 95 ms
80,296 KB
testcase_16 AC 114 ms
94,040 KB
testcase_17 AC 95 ms
82,092 KB
testcase_18 AC 105 ms
87,968 KB
testcase_19 AC 114 ms
91,704 KB
testcase_20 AC 90 ms
78,148 KB
testcase_21 AC 93 ms
80,496 KB
testcase_22 AC 93 ms
79,168 KB
testcase_23 AC 102 ms
85,148 KB
testcase_24 AC 100 ms
83,972 KB
testcase_25 AC 113 ms
91,840 KB
testcase_26 AC 125 ms
92,760 KB
testcase_27 AC 126 ms
92,556 KB
testcase_28 AC 125 ms
92,928 KB
testcase_29 AC 126 ms
92,792 KB
testcase_30 AC 125 ms
92,732 KB
testcase_31 AC 126 ms
92,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod=10**9+7
n=int(input())
arr=list(map(int,input().split()))
if 0 in arr:
    print(0)
    exit()
rs=[-1]*n
tmp=1
pos=0
for i in range(n):
    for j in range(max(i,pos),n):
        tmp*=arr[j]
        if tmp>=10**9:
            rs[i]=j
            pos=j
            tmp//=arr[j]
            break
    else:
        rs[i]=n
        pos=n
    tmp//=arr[i]
imos1=[0]*(n+1)
imos2=[0]*(n+1)
for i in range(n):
    imos1[i]=rs[i]-i
    imos2[i+1]+=-1
    if rs[i]+1<=n:
        imos2[rs[i]+1]+=1
for i in range(1,n+1):
    imos2[i]+=imos2[i-1]
for i in range(n):
    imos1[i]+=imos2[i]
for i in range(1,n+1):
    imos1[i]+=imos1[i-1]
ans=1
for i in range(n):
    ans*=pow(arr[i],imos1[i],mod)
    ans%=mod
print(ans)
0