結果
| 問題 |
No.510 二次漸化式
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 18:20:03 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 793 bytes |
| コンパイル時間 | 286 ms |
| コンパイル使用メモリ | 81,956 KB |
| 実行使用メモリ | 86,672 KB |
| 最終ジャッジ日時 | 2025-06-12 18:21:03 |
| 合計ジャッジ時間 | 27,531 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 21 TLE * 1 -- * 12 |
ソースコード
MOD = 10**9 + 7
n = int(input())
q = int(input())
x = [0] * n
y = [0] * n
for _ in range(q):
parts = input().split()
if parts[0] == 'x':
idx = int(parts[1])
v = int(parts[2])
x[idx] = v
elif parts[0] == 'y':
idx = int(parts[1])
v = int(parts[2])
y[idx] = v
else:
i = int(parts[1])
if i == 0:
print(1 % MOD)
continue
total = 0
current_b = 1 # b_0
# j=0
total += x[0] * (current_b ** 2)
for j in range(1, i):
# compute b_j using y[j-1]
current_b = (y[j-1] * current_b + 1) % MOD
term = x[j] * (current_b ** 2)
total += term
total %= MOD
ans = (1 + total) % MOD
print(ans)
gew1fw