結果

問題 No.1084 積の積
ユーザー uni_python
提出日時 2020-06-20 10:19:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 185 ms / 2,000 ms
コード長 714 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 82,168 KB
実行使用メモリ 89,564 KB
最終ジャッジ日時 2024-07-03 16:57:22
合計ジャッジ時間 4,560 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
mod=10**9+7

def main():
    import bisect
    
    N=I()
    A=LI()
    ans=1
    flag=0
    if min(A)==0:
        print(0)
    else:

            
        ceil=10**9
        now=1
        temp=1
        ans=1
        l=0
        
        for r in range(N):
            now*=A[r]
            temp=(temp*pow(A[r],r-l+1,mod))%mod
            
            while now>=ceil:
                temp=(temp*pow(now,mod-2,mod))
                now=now//A[l]
                l+=1
            ans=(ans*temp)%mod
            
        print(ans%mod)
            


main()
0