結果
| 問題 |
No.1084 積の積
|
| コンテスト | |
| ユーザー |
ayaoni
|
| 提出日時 | 2020-11-26 14:56:26 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 822 bytes |
| コンパイル時間 | 170 ms |
| コンパイル使用メモリ | 82,292 KB |
| 実行使用メモリ | 101,720 KB |
| 最終ジャッジ日時 | 2024-07-23 20:49:50 |
| 合計ジャッジ時間 | 4,444 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 RE * 1 |
| other | AC * 24 RE * 3 |
ソースコード
import sys
from itertools import accumulate
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
A = LI()
mod = 10**9+7
count = [0]*(N+2)
a = A[0] # 区間[l,r)の積
l,r = 0,1
while r <= N:
if a < 10**9:
if r <= N-1:
a *= A[r]
r += 1
else:
count[l] += r-l
count[l+1] -= r-l+1
count[r+1] += 1
if l < r:
a //= A[l]
l += 1
else:
break
else:
count[l] += r-l-1
count[l+1] -= r-l
count[r] += 1
a //= A[l]
l += 1
count = list(accumulate(list(accumulate(count))))
ans = 1
for i in range(N):
ans *= pow(A[i],count[i],mod)
ans %= mod
print(ans)
ayaoni