結果

問題 No.2685 Cell Proliferation (Easy)
ユーザー ma_tw
提出日時 2024-03-19 02:46:49
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 682 bytes
コンパイル時間 2,177 ms
コンパイル使用メモリ 199,104 KB
最終ジャッジ日時 2025-02-20 07:22:53
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/modint>
using mint = atcoder::modint998244353;

int main() {
    int p1, p2, q1, q2, t;
    cin >> p1 >> p2 >> q1 >> q2 >> t;
    vector dp(t + 1, vector<mint> (t + 1));
    mint p = mint(p1) / p2;
    mint q = mint(q1) / q2;
    dp[0][0] = 1;
    for (int i = 0; i < t; i++) {
        mint sm = 0;
        for (int j = 0; j <= i; j++) {
            sm += dp[i][j];
        }
        dp[i + 1][0] = sm * p;
        for (int j = 0; j <= i; j++) {
            dp[i + 1][j + 1] = q.pow(j + 1) * dp[i][j];
        }
    }
    mint ans = 0;
    for (int j = 0; j <= t; j++) ans += dp[t][j];
    cout << ans.val() << endl;
}
0