結果

問題 No.2685 Cell Proliferation (Easy)
ユーザー umezoumezo
提出日時 2024-03-22 08:23:48
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 1,026 bytes
コンパイル時間 3,188 ms
コンパイル使用メモリ 248,492 KB
実行使用メモリ 10,368 KB
最終ジャッジ日時 2024-03-22 08:23:53
合計ジャッジ時間 4,616 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 14 ms
10,368 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 9 ms
8,064 KB
testcase_04 AC 9 ms
8,576 KB
testcase_05 AC 4 ms
6,676 KB
testcase_06 AC 8 ms
7,040 KB
testcase_07 AC 8 ms
7,552 KB
testcase_08 AC 9 ms
7,936 KB
testcase_09 AC 10 ms
9,088 KB
testcase_10 AC 7 ms
7,040 KB
testcase_11 AC 6 ms
6,676 KB
testcase_12 AC 6 ms
6,676 KB
testcase_13 AC 9 ms
7,680 KB
testcase_14 AC 10 ms
8,320 KB
testcase_15 AC 13 ms
10,112 KB
testcase_16 AC 8 ms
7,936 KB
testcase_17 AC 3 ms
6,676 KB
testcase_18 AC 7 ms
6,912 KB
testcase_19 AC 8 ms
7,296 KB
testcase_20 AC 4 ms
6,676 KB
testcase_21 AC 3 ms
6,676 KB
testcase_22 AC 13 ms
9,600 KB
testcase_23 AC 5 ms
6,676 KB
testcase_24 AC 10 ms
9,472 KB
testcase_25 AC 10 ms
8,832 KB
testcase_26 AC 8 ms
7,680 KB
testcase_27 AC 4 ms
6,676 KB
testcase_28 AC 7 ms
7,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;

const int MOD=998244353;
ll modpow(ll x,ll n){
  x%=MOD;
  ll ans=1;
  while(n){
    if(n&1) ans=ans*x%MOD;
    x=x*x%MOD;
    n/=2;
  }
  return ans;
}
ll dp[1010][1010];
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  ll p1,p2,q1,q2,t;
  cin>>p1>>p2>>q1>>q2>>t;
  ll p=p1*modpow(p2,MOD-2)%MOD;
  ll q=q1*modpow(q2,MOD-2)%MOD;
  vector<ll> Q(t+2);
  Q[0]=1;
  rep(i,t+1) Q[i+1]=Q[i]*q%MOD;
  for(int i=1;i<=t;i++) Q[i]=Q[i]*Q[i-1]%MOD;
  dp[0][0]=1;
  for(int i=0;i<=t;i++){
    for(int j=0;j<=t;j++){
      if(dp[i][j]==0) continue;
      dp[i+1][j+1]=(dp[i+1][j+1]+dp[i][j])%MOD;
    }
    if(i==t) break;
    for(int j=1;j<=t;j++){
      if(dp[i+1][j]==0) continue;
      dp[i+1][0]=(dp[i+1][0]+dp[i+1][j]*p%MOD*Q[j-1]%MOD)%MOD;
    }
  }
  ll ans=0;
  for(int j=0;j<=t+1;j++) ans=(ans+dp[t][j]*Q[j]%MOD)%MOD;
  cout<<ans<<endl;
    
  return 0;
}
0