結果

問題 No.2685 Cell Proliferation (Easy)
ユーザー 👑 rin204rin204
提出日時 2024-03-03 13:29:00
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 843 bytes
コンパイル時間 2,964 ms
コンパイル使用メモリ 249,888 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-03-20 20:16:55
合計ジャッジ時間 4,337 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#include "atcoder/modint.hpp"
using mint = atcoder::modint998244353;

int main() {
    int p1, p2, q1, q2, T;
    cin >> p1 >> p2 >> q1 >> q2 >> T;
    mint p = mint(p1) / p2;
    mint q = mint(q1) / q2;
    vector<mint> powQ(T + 1, 1);
    for (int i = 1; i <= T; i++) {
        powQ[i] = powQ[i - 1] * q;
    }

    if (p == 0) {
        mint ans = 1;
        for (int i = 1; i <= T; i++) {
            ans *= powQ[i];
        }
        cout << ans.val() << endl;
        return 0;
    }

    vector<mint> dp(T + 2, 0);
    dp[0] = 1;
    for (int i = 1; i <= T + 1; i++) {
        mint alive = 1;
        for (int j = i - 1; j >= 0; j--) {
            dp[i] += dp[j] * alive * p;
            alive *= powQ[i - j];
        }
    }
    mint ans = dp.back() / p;
    cout << ans.val() << endl;
}
0