結果

問題 No.1084 積の積
ユーザー 👑 rin204rin204
提出日時 2022-07-06 07:16:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 183 ms / 2,000 ms
コード長 446 bytes
コンパイル時間 385 ms
コンパイル使用メモリ 82,172 KB
実行使用メモリ 87,464 KB
最終ジャッジ日時 2024-05-10 04:18:16
合計ジャッジ時間 4,931 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
51,760 KB
testcase_01 AC 38 ms
53,132 KB
testcase_02 AC 38 ms
52,332 KB
testcase_03 AC 39 ms
52,156 KB
testcase_04 AC 183 ms
80,496 KB
testcase_05 AC 56 ms
76,508 KB
testcase_06 AC 182 ms
80,152 KB
testcase_07 AC 38 ms
52,756 KB
testcase_08 AC 38 ms
52,548 KB
testcase_09 AC 62 ms
82,020 KB
testcase_10 AC 38 ms
52,120 KB
testcase_11 AC 51 ms
62,680 KB
testcase_12 AC 87 ms
72,180 KB
testcase_13 AC 130 ms
82,968 KB
testcase_14 AC 75 ms
69,104 KB
testcase_15 AC 75 ms
69,084 KB
testcase_16 AC 142 ms
87,464 KB
testcase_17 AC 82 ms
70,988 KB
testcase_18 AC 109 ms
78,724 KB
testcase_19 AC 130 ms
83,212 KB
testcase_20 AC 65 ms
66,432 KB
testcase_21 AC 76 ms
69,040 KB
testcase_22 AC 69 ms
67,864 KB
testcase_23 AC 96 ms
75,812 KB
testcase_24 AC 92 ms
73,320 KB
testcase_25 AC 126 ms
83,056 KB
testcase_26 AC 133 ms
83,968 KB
testcase_27 AC 133 ms
84,180 KB
testcase_28 AC 133 ms
83,160 KB
testcase_29 AC 132 ms
82,692 KB
testcase_30 AC 133 ms
83,748 KB
testcase_31 AC 129 ms
83,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7

n = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
    exit()

prod = 1
prod_all = 1
ans = 1
r = 0
A.append(10 ** 10)
for l in range(n):
    while prod * A[r] < 10 ** 9:
        prod *= A[r]
        prod_all *= prod
        prod_all %= MOD
        r += 1
    ans *= prod_all
    ans %= MOD
    le = r - l
    prod //= A[l]
    prod_all *= pow(A[l], le * (MOD - 2), MOD)
    prod_all %= MOD
print(ans)
0