結果

問題 No.2688 Cell Proliferation (Hard)
ユーザー eve__fuyukieve__fuyuki
提出日時 2024-03-21 01:35:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,679 bytes
コンパイル時間 3,897 ms
コンパイル使用メモリ 243,924 KB
実行使用メモリ 11,668 KB
最終ジャッジ日時 2024-03-21 01:36:02
合計ジャッジ時間 9,333 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 4 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0