結果

問題 No.1084 積の積
ユーザー uni_pythonuni_python
提出日時 2020-06-19 23:27:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,584 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 87,176 KB
実行使用メモリ 92,448 KB
最終ジャッジ日時 2023-09-16 15:42:14
合計ジャッジ時間 9,030 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,472 KB
testcase_01 AC 75 ms
70,964 KB
testcase_02 AC 75 ms
71,184 KB
testcase_03 AC 75 ms
70,964 KB
testcase_04 WA -
testcase_05 AC 91 ms
88,320 KB
testcase_06 AC 351 ms
90,504 KB
testcase_07 AC 74 ms
71,336 KB
testcase_08 AC 72 ms
71,184 KB
testcase_09 AC 94 ms
89,652 KB
testcase_10 AC 72 ms
71,428 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

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:
        #尺取り法で10**9未満なら追加して,そこから尺取りの長さ分で色々
        #右側からの累積累積積みたいなの求めておくか
        S=[1]*(N+1)
        for i in range(N):
            S[i+1]=(S[i]*pow(A[i],(i+2),mod))%mod
            
        S2=[1]*(N+1)
        for i in range(N):
            S2[i+1]=(S2[i]*A[i])%mod
            

            
        ceil=10**9
        now=1
        ans=1
        l=-1#次に抜くのがl+1
        r=0#次に加えるもの
        
        # print(S)
        # print(S2)
        
        flag=0#終了フラグ
        while flag==0:
            while now*A[r]<ceil:
                
                temp=(S2[r+1]*pow(S2[l+1],mod-2,mod))%mod
                aaa=pow(temp,l+2,mod)
                bbb=(S[r+1]*pow(aaa,mod-2,mod)*pow(S[l+1],mod-2,mod))%mod
                
                ans=(ans*bbb)%mod
                # print("S2",S2[r+1],S2[l+1],temp)
                # print("ans",ans,l,r)
                # print(temp,aaa,bbb)
                # print("---")
                r+=1
                if r==N:
                    flag=1
                    break
                now=now*A[r]
                
            l+=1
            now=now//A[l]
            
        print(ans)
            


main()
0