結果
| 問題 |
No.1084 積の積
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-19 22:58:41 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 753 bytes |
| コンパイル時間 | 148 ms |
| コンパイル使用メモリ | 82,356 KB |
| 実行使用メモリ | 92,544 KB |
| 最終ジャッジ日時 | 2024-07-03 15:27:22 |
| 合計ジャッジ時間 | 3,283 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 RE * 1 |
| other | AC * 24 RE * 3 |
ソースコード
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 9
def main():
N = int(input())
A = list(map(int,input().split()))
r = 0
now = 1
cnt = [0] * (N + 1)
for l in range(N):
while r < N and now * A[r] < INF:
now *= A[r]
r += 1
if l > 0:
cnt[l - 1] -= r - l + 1
if r > 0:
cnt[r - 1] += 1
if l > 1:
cnt[l - 2] += r - l
now //= A[l]
for i in range(N - 1,-1,-1):
cnt[i] += cnt[i + 1]
for i in range(N - 1,-1,-1):
cnt[i] += cnt[i + 1]
ans = 1
for i in range(N):
ans *= pow(A[i],cnt[i],MOD)
ans %= MOD
print(ans)
if __name__ == '__main__':
main()