結果
問題 |
No.2688 Cell Proliferation (Hard)
|
ユーザー |
![]() |
提出日時 | 2024-03-20 23:19:19 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 658 ms / 4,000 ms |
コード長 | 1,852 bytes |
コンパイル時間 | 5,810 ms |
コンパイル使用メモリ | 318,144 KB |
実行使用メモリ | 37,112 KB |
最終ジャッジ日時 | 2024-09-30 09:25:35 |
合計ジャッジ時間 | 16,538 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#include <atcoder/all> #include <bits/stdc++.h> using ll = long long; using ull = unsigned long long; #define rep(i, n) for(int i = 0; i < (int)(n); i++) #define REP(i, m, n) for(int i = (int)(m); i < (int)(n); i++) using namespace std; using namespace atcoder; using mint = modint998244353; const int inf = 1000000007; const ll longinf = 1ll << 60; namespace fps { using P = vector<mint>; void dft(P &f) { atcoder::internal::butterfly(f); } void idft(P &f) { atcoder::internal::butterfly_inv(f); mint c = mint(f.size()).inv(); for(auto &e : f) e *= c; } P inv(P &f, int size = -1) { assert(f[0] != 0); if(size == -1) { size = f.size(); } P g(size); g[0] = f[0].inv(); for(int d = 1; d < size; d <<= 1) { P gg(2 * d), ff(2 * d); for(int j = 0; j < min((int)f.size(), 2 * d); j++) ff[j] = f[j]; for(int j = 0; j < d; j++) { gg[j] = g[j]; } dft(ff); dft(gg); for(int j = 0; j < 2 * d; j++) ff[j] *= gg[j]; idft(ff); for(int j = 0; j < d; j++) { ff[j] = 0; } dft(ff); for(int j = 0; j < 2 * d; j++) ff[j] *= gg[j]; idft(ff); for(int j = d; j < min(2 * d, size); j++) g[j] = -ff[j]; } return g; } } // namespace fps int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int p1, p2, q1, q2, t; cin >> p1 >> p2 >> q1 >> q2 >> t; mint p = mint(p1) / p2; mint q = mint(q1) / q2; vector<mint> bumbo(t + 1), bunshi(t + 1); ll c = 0; rep(i, t + 1) { bumbo[i] = -p * q.pow(c); c += i; bunshi[i] = q.pow(c); } bumbo[0] = 1; auto ret = convolution(bunshi, fps::inv(bumbo)); cout << ret[t].val() << endl; return 0; }