結果
| 問題 | No.1084 積の積 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-19 22:58:41 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 753 bytes |
| 記録 | |
| コンパイル時間 | 644 ms |
| コンパイル使用メモリ | 84,992 KB |
| 実行使用メモリ | 93,568 KB |
| 最終ジャッジ日時 | 2026-03-24 23:29:44 |
| 合計ジャッジ時間 | 2,885 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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()