結果

問題 No.2685 Cell Proliferation (Easy)
ユーザー てんぷらてんぷら
提出日時 2024-03-20 22:02:12
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 1,037 bytes
コンパイル時間 5,610 ms
コンパイル使用メモリ 314,104 KB
実行使用メモリ 34,816 KB
最終ジャッジ日時 2024-03-20 22:02:38
合計ジャッジ時間 7,853 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
34,816 KB
testcase_01 AC 58 ms
34,816 KB
testcase_02 AC 25 ms
34,816 KB
testcase_03 AC 40 ms
34,816 KB
testcase_04 AC 43 ms
34,816 KB
testcase_05 AC 28 ms
34,816 KB
testcase_06 AC 34 ms
34,816 KB
testcase_07 AC 37 ms
34,816 KB
testcase_08 AC 39 ms
34,816 KB
testcase_09 AC 47 ms
34,816 KB
testcase_10 AC 34 ms
34,816 KB
testcase_11 AC 30 ms
34,816 KB
testcase_12 AC 31 ms
34,816 KB
testcase_13 AC 38 ms
34,816 KB
testcase_14 AC 41 ms
34,816 KB
testcase_15 AC 55 ms
34,816 KB
testcase_16 AC 40 ms
34,816 KB
testcase_17 AC 25 ms
34,816 KB
testcase_18 AC 34 ms
34,816 KB
testcase_19 AC 35 ms
34,816 KB
testcase_20 AC 27 ms
34,816 KB
testcase_21 AC 26 ms
34,816 KB
testcase_22 AC 50 ms
34,816 KB
testcase_23 AC 30 ms
34,816 KB
testcase_24 AC 57 ms
34,816 KB
testcase_25 AC 45 ms
34,816 KB
testcase_26 AC 37 ms
34,816 KB
testcase_27 AC 27 ms
34,816 KB
testcase_28 AC 39 ms
34,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

vector<vector<mint>> dp;
vector<vector<int>> memo;
mint rec(int t, int x, mint p, mint q) {
    if(memo[t][x]) {
        return dp[t][x];
    }
    if(t == 0) {
        return 1;
    }
    mint ret = p * rec(t - 1, 1, p, q) + q.pow(x) * rec(t - 1, x + 1, p, q);
    memo[t][x] = 1;
    return dp[t][x] = ret;
}

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;
    dp.resize(2000), memo.resize(2000);
    rep(i, 2000) dp[i].resize(2000);
    rep(i, 2000) memo[i].resize(2000);
    cout << rec(t, 1, p, q).val() << endl;
    return 0;
}
0