結果

問題 No.2685 Cell Proliferation (Easy)
ユーザー SSRSSSRS
提出日時 2024-03-20 21:33:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 942 bytes
コンパイル時間 2,139 ms
コンパイル使用メモリ 204,468 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-03-20 21:33:08
合計ジャッジ時間 3,399 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 4 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 3 ms
6,548 KB
testcase_04 AC 3 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 3 ms
6,548 KB
testcase_09 AC 4 ms
6,548 KB
testcase_10 AC 3 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 4 ms
6,548 KB
testcase_16 AC 3 ms
6,548 KB
testcase_17 AC 2 ms
6,548 KB
testcase_18 AC 3 ms
6,548 KB
testcase_19 AC 2 ms
6,548 KB
testcase_20 AC 2 ms
6,548 KB
testcase_21 AC 2 ms
6,548 KB
testcase_22 AC 4 ms
6,548 KB
testcase_23 AC 2 ms
6,548 KB
testcase_24 AC 4 ms
6,548 KB
testcase_25 AC 3 ms
6,548 KB
testcase_26 AC 3 ms
6,548 KB
testcase_27 AC 2 ms
6,548 KB
testcase_28 AC 3 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
long long modpow(long long a, long long b){
  long long ans = 1;
  while (b > 0){
    if (b % 2 == 1){
      ans *= a;
      ans %= MOD;
    }
    a *= a;
    a %= MOD;
    b /= 2;
  }
  return ans;
}
long long modinv(long long a){
  return modpow(a, MOD - 2);
}
int main(){
  long long P1, P2, Q1, Q2;
  int T;
  cin >> P1 >> P2 >> Q1 >> Q2 >> T;
  long long P = P1 * modinv(P2) % MOD;
  long long Q = Q1 * modinv(Q2) % MOD;
  vector<long long> POW(T + 1);
  POW[0] = 1;
  for (int i = 1; i <= T; i++){
    POW[i] = POW[i - 1] * Q % MOD;
  }
  vector<long long> dp(T + 1, 0);
  dp[0] = 1;
  long long ans = 0;
  for (int i = 0; i <= T; i++){
    long long tmp = dp[i];
    for (int j = 1; j <= T - i; j++){
      dp[i + j] += tmp * P;
      dp[i + j] %= MOD;
      tmp *= POW[j];
      tmp %= MOD;
    }
    ans += tmp;
  }
  ans %= MOD;
  cout << ans << endl;
}
0