結果
問題 | No.510 二次漸化式 |
ユーザー | xxxxxxxxxxxxxxxxxxxx |
提出日時 | 2017-04-28 23:47:22 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,123 bytes |
コンパイル時間 | 1,512 ms |
コンパイル使用メモリ | 167,656 KB |
実行使用メモリ | 10,624 KB |
最終ジャッジ日時 | 2023-10-11 19:53:11 |
合計ジャッジ時間 | 25,237 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
8,700 KB |
testcase_01 | AC | 2 ms
4,348 KB |
testcase_02 | AC | 59 ms
4,348 KB |
testcase_03 | AC | 60 ms
4,352 KB |
testcase_04 | AC | 59 ms
4,348 KB |
testcase_05 | AC | 59 ms
4,348 KB |
testcase_06 | AC | 392 ms
4,352 KB |
testcase_07 | AC | 383 ms
4,348 KB |
testcase_08 | AC | 387 ms
4,352 KB |
testcase_09 | AC | 388 ms
4,348 KB |
testcase_10 | AC | 23 ms
4,348 KB |
testcase_11 | AC | 23 ms
4,352 KB |
testcase_12 | AC | 23 ms
4,348 KB |
testcase_13 | AC | 23 ms
4,348 KB |
testcase_14 | AC | 23 ms
4,348 KB |
testcase_15 | AC | 22 ms
4,352 KB |
testcase_16 | AC | 2,411 ms
6,212 KB |
testcase_17 | AC | 2,323 ms
6,144 KB |
testcase_18 | AC | 2,355 ms
6,376 KB |
testcase_19 | AC | 2,326 ms
6,288 KB |
testcase_20 | AC | 2,361 ms
6,296 KB |
testcase_21 | AC | 2,369 ms
6,188 KB |
testcase_22 | AC | 2,396 ms
6,288 KB |
testcase_23 | TLE | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
ソースコード
#include <bits/stdc++.h> using namespace std; const long MOD = 1000000000 + 7; int main() { int n, q; cin >> n >> q; vector<long>x(n); vector<long>y(n); vector<long>a(n + 1); vector<long>b(n + 1); a[0] = 1; b[0] = 1; for (int i = 0; i < n; ++i) { a[i + 1] = (x[i] * ((b[i] * b[i]) % MOD) % MOD) + a[i]; b[i + 1] = y[i] * b[i] + 1; a[i + 1] %= MOD; b[i + 1] %= MOD; } for (int t = 0; t < q; ++t) { char c; cin >> c; switch (c) { case 'x': { int idx, val; cin >> idx >> val; x[idx] = val; for (int i = idx; i < n; ++i) { a[i + 1] = (x[i] * ((b[i] * b[i]) % MOD) % MOD) + a[i]; a[i + 1] %= MOD; } } break; case 'y': { int idx, val; cin >> idx >> val; y[idx] = val; for (int i = idx; i < n; ++i) { a[i + 1] = (x[i] * ((b[i] * b[i]) % MOD) % MOD) + a[i]; b[i + 1] = y[i] * b[i] + 1; a[i + 1] %= MOD; b[i + 1] %= MOD; } } break; case 'a': { int idx; cin >> idx; cout << a[idx] << endl; } } } return 0; }