結果

問題 No.2685 Cell Proliferation (Easy)
ユーザー とりゐとりゐ
提出日時 2024-03-20 21:58:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 1,399 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 78,788 KB
最終ジャッジ日時 2024-03-20 21:58:39
合計ジャッジ時間 4,115 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
62,572 KB
testcase_01 AC 147 ms
78,788 KB
testcase_02 AC 64 ms
75,716 KB
testcase_03 AC 105 ms
78,788 KB
testcase_04 AC 117 ms
78,788 KB
testcase_05 AC 78 ms
78,788 KB
testcase_06 AC 93 ms
78,788 KB
testcase_07 AC 100 ms
78,788 KB
testcase_08 AC 104 ms
78,788 KB
testcase_09 AC 149 ms
78,788 KB
testcase_10 AC 92 ms
78,788 KB
testcase_11 AC 84 ms
78,788 KB
testcase_12 AC 86 ms
78,788 KB
testcase_13 AC 101 ms
78,788 KB
testcase_14 AC 109 ms
78,788 KB
testcase_15 AC 139 ms
78,788 KB
testcase_16 AC 104 ms
78,788 KB
testcase_17 AC 61 ms
73,540 KB
testcase_18 AC 90 ms
78,788 KB
testcase_19 AC 94 ms
78,788 KB
testcase_20 AC 75 ms
78,788 KB
testcase_21 AC 70 ms
78,532 KB
testcase_22 AC 130 ms
78,788 KB
testcase_23 AC 80 ms
78,788 KB
testcase_24 AC 164 ms
78,788 KB
testcase_25 AC 117 ms
78,788 KB
testcase_26 AC 101 ms
78,788 KB
testcase_27 AC 75 ms
78,788 KB
testcase_28 AC 105 ms
78,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod=998244353
table_size=2*10**5

fac=[1]*(table_size+1)
finv=[1]*(table_size+1)

for i in range(2,table_size+1):
  fac[i]=fac[i-1]*i%mod
finv[table_size]=pow(fac[table_size],mod-2,mod)
for i in range(table_size-1,-1,-1):
  finv[i]=finv[i+1]*(i+1)%mod

def rebuild(n):
  global table_size,fac,finv
  fac+=[0]*(n-table_size)
  fac+=[0]*(n-table_size)
  finv+=[0]*(n-table_size)
  for i in range(table_size+1,n+1):
    fac[i]=fac[i-1]*i%mod
  finv[n]=inv(fac[n])
  for i in range(n-1,table_size,-1):
    finv[i]=finv[i+1]*(i+1)%mod
  table_size=n

def binom(n,k):
  if n<0 or k<0:
    return 0
  if k>n:
    return 0
  if n>table_size:
    rebuild(n+10**4)
  return (fac[n]*finv[k]%mod)*finv[n-k]%mod

def fpow(x,k):
  res=1
  while k:
    if k&1:
      res=res*x%mod
    x=x*x%mod
    k>>=1
  return res

def inv(a):
  if a<table_size:
    return fac[a-1]*finv[a]%mod
  return fpow(a,mod-2)

def modint_to_frac(a,mod):
  a%=mod
  if a==0:
    return '0/1'
  for X in range(1,10000):
    Y=a*X%mod
    if 0<Y<10000:
      return str(Y)+'/'+str(X)
    if mod-10000<Y<mod:
      return '-'+str(mod-Y)+'/'+str(X)
  return 'inexpressible'



P1,P2,Q1,Q2,T=map(int,input().split())
P=P1*inv(P2)%mod
Q=Q1*inv(Q2)%mod

dp=[0]*(T+1)
dp[0]=1
for t in range(1,T+1):
  for t1 in range(t):
    dp[t]+=dp[t1]*P
    dp[t]%=mod
  for t2 in range(t):
    dp[t2]=dp[t2]*fpow(Q,t-t2)
    dp[t2]%=mod

print(sum(dp)%mod)
0