結果
問題 |
No.2688 Cell Proliferation (Hard)
|
ユーザー |
![]() |
提出日時 | 2024-03-21 01:35:53 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,679 bytes |
コンパイル時間 | 3,753 ms |
コンパイル使用メモリ | 233,740 KB |
最終ジャッジ日時 | 2025-02-20 10:25:54 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | TLE * 1 -- * 25 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/convolution> #include <atcoder/modint> using namespace std; using namespace atcoder; using mint = modint998244353; void fast_io() { ios::sync_with_stdio(false); std::cin.tie(nullptr); } vector<mint> f, g, h; int n; void calc(int l1, int r1, int l2, int r2) { while (h.size() < r1 + r2 - 1) { h.push_back(0); } vector<mint> f1, f2; for (int i = l1; i < r1; i++) { f1.push_back(f[i]); } for (int i = l2; i < r2; i++) { f2.push_back(g[i]); } vector<mint> fg = convolution(f1, f2); for (int i = 0; i < fg.size(); i++) { h[i + l1 + l2] += fg[i]; } } mint append(mint a, mint b) { f.push_back(a); g.push_back(b); n++; int m = (n + 1) & -(n + 1); int s = 0; if (m <= n) { int add = 1; while (add <= m) { calc(n - add, n, s, s + add); calc(s, s + add, n - add, n); s += add; add <<= 1; } } else { int add = 1; while (add < (m >> 1)) { calc(n - add, n, s, s + add); calc(s, s + add, n - add, n); s += add; add <<= 1; } calc(n - add, n, s, s + add); } return h[n - 1]; } int main() { fast_io(); int pp1, pp2, qq1, qq2, t; cin >> pp1 >> pp2 >> qq1 >> qq2 >> t; mint p = mint(pp1) / pp2, q = mint(qq1) / qq2; vector<mint> birth(t + 2), remain(t + 2); birth[0] = 1; for (int i = 1; i <= t + 1; i++) { remain[i] = append(birth[i - 1], q.pow(i * (i - 1) / 2)); birth[i] = remain[i] * p; } cout << remain[t + 1].val() << endl; }