結果

問題 No.1084 積の積
ユーザー wolgnikwolgnik
提出日時 2020-06-19 22:11:02
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 179 ms / 2,000 ms
コード長 627 bytes
コンパイル時間 265 ms
コンパイル使用メモリ 87,192 KB
実行使用メモリ 93,112 KB
最終ジャッジ日時 2023-09-16 14:31:08
合計ジャッジ時間 4,828 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,464 KB
testcase_01 AC 70 ms
71,360 KB
testcase_02 AC 73 ms
71,308 KB
testcase_03 AC 70 ms
71,240 KB
testcase_04 AC 179 ms
91,508 KB
testcase_05 AC 87 ms
88,272 KB
testcase_06 AC 178 ms
91,328 KB
testcase_07 AC 69 ms
71,316 KB
testcase_08 AC 70 ms
71,460 KB
testcase_09 AC 89 ms
89,460 KB
testcase_10 AC 69 ms
71,408 KB
testcase_11 AC 81 ms
76,736 KB
testcase_12 AC 91 ms
82,264 KB
testcase_13 AC 103 ms
90,768 KB
testcase_14 AC 88 ms
80,004 KB
testcase_15 AC 88 ms
79,828 KB
testcase_16 AC 109 ms
93,112 KB
testcase_17 AC 90 ms
81,476 KB
testcase_18 AC 97 ms
86,888 KB
testcase_19 AC 104 ms
90,712 KB
testcase_20 AC 85 ms
78,056 KB
testcase_21 AC 89 ms
79,864 KB
testcase_22 AC 87 ms
78,568 KB
testcase_23 AC 95 ms
84,356 KB
testcase_24 AC 92 ms
83,336 KB
testcase_25 AC 104 ms
90,864 KB
testcase_26 AC 114 ms
91,948 KB
testcase_27 AC 116 ms
91,748 KB
testcase_28 AC 114 ms
91,864 KB
testcase_29 AC 114 ms
91,896 KB
testcase_30 AC 112 ms
91,860 KB
testcase_31 AC 119 ms
91,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
if 0 in a:
  print(0)
  exit(0)
rs = [0] * N
r = 0
x = 1
imos = [0] * (N + 1)
imosliner = [0] * (N + 1)
for l in range(N):
  while r < N:
    if x * a[r] >= 10 ** 9:
      rs[l] = r
      break
    x *= a[r]
    r += 1
  else: rs[l] = r
  x //= a[l]
  imos[l] += rs[l] - l
  imosliner[l] -= 1
  imosliner[rs[l]] += 1
#print(imos, imosliner)
for i in range(N):
  imos[i + 1] += imos[i] + imosliner[i]
  imosliner[i + 1] += imosliner[i]
res = 1
for i in range(N):
  res *= pow(a[i], imos[i], mod)
  res %= mod
print(res)
0