結果

問題 No.1084 積の積
ユーザー NoneNone
提出日時 2021-03-17 22:43:11
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,013 bytes
コンパイル時間 134 ms
コンパイル使用メモリ 81,780 KB
実行使用メモリ 89,228 KB
最終ジャッジ日時 2024-04-27 14:39:54
合計ジャッジ時間 5,869 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
54,020 KB
testcase_01 AC 36 ms
52,120 KB
testcase_02 AC 35 ms
52,068 KB
testcase_03 AC 35 ms
52,472 KB
testcase_04 AC 208 ms
88,040 KB
testcase_05 RE -
testcase_06 AC 203 ms
88,124 KB
testcase_07 RE -
testcase_08 AC 35 ms
52,660 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 55 ms
64,144 KB
testcase_12 AC 111 ms
74,452 KB
testcase_13 AC 183 ms
84,308 KB
testcase_14 AC 94 ms
70,636 KB
testcase_15 AC 90 ms
70,520 KB
testcase_16 AC 205 ms
87,424 KB
testcase_17 AC 107 ms
72,892 KB
testcase_18 AC 147 ms
79,844 KB
testcase_19 AC 184 ms
83,916 KB
testcase_20 AC 78 ms
69,024 KB
testcase_21 AC 97 ms
70,204 KB
testcase_22 AC 85 ms
68,660 KB
testcase_23 AC 130 ms
77,440 KB
testcase_24 AC 120 ms
74,364 KB
testcase_25 AC 185 ms
84,112 KB
testcase_26 AC 218 ms
88,508 KB
testcase_27 AC 218 ms
88,632 KB
testcase_28 AC 214 ms
88,576 KB
testcase_29 AC 219 ms
88,556 KB
testcase_30 AC 218 ms
88,660 KB
testcase_31 AC 217 ms
88,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def syakutori(A):

    total=1

    def merge(total,Ai):
        total*=Ai
        return total

    def inv_merge(total,Ai):
        total//=Ai
        return total

    def is_possible_merge(total,Ai):
        return total*Ai<10**9

    N=len(A)
    left, right, right_max=0,0,N
    res=1
    T=1
    S=1
    for left in range(right_max):
        while right<right_max and is_possible_merge(total,A[right]):
            total = merge(total,A[right])
            S*=A[right]
            S%=MOD
            T*=S
            T%=MOD
            right+=1
        res*=T
        res%=MOD
        if right==left:
            right+=1
        else:
            total = inv_merge(total,A[left])
            S*=pow(A[left],MOD-2,MOD)
            S%=MOD
            T*=pow(A[left],MOD-1-(right-left),MOD)
            T%=MOD


    return res


#########################################
import sys
input = sys.stdin.readline

K=10**9

MOD=10**9+7

N=int(input())
A=list(map(int, input().split()))
res=syakutori(A)
print(res)
0