結果

問題 No.2685 Cell Proliferation (Easy)
ユーザー SPD_9X2
提出日時 2024-03-01 15:31:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 309 ms / 2,000 ms
コード長 910 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 82,140 KB
実行使用メモリ 93,968 KB
最終ジャッジ日時 2024-09-30 06:45:33
合計ジャッジ時間 5,225 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

想定解?

solve(L,R) = 
L-0.000001 秒を迎えた細胞ひとつが、R+0.9秒でいくつになっているか?

"""

import sys
sys.setrecursionlimit(10**6+10)

mod = 998244353

P1,P2,Q1,Q2,T = map(int,input().split())

P12 = P1 * pow(P2,mod-2,mod) % mod
Q12 = Q1 * pow(Q2,mod-2,mod) % mod

lis = [[None] * (T+1) for i in range(T+1)]

def solve(L,R):

    #print (L,R)
    if lis[L][R] != None:
        return lis[L][R]

    assert L <= R

    live = pow(Q12,L,mod)

    # 自分
    if L == R:
        if L == 0:
            now_me = 1
        else:
            now_me = live
    else:
        if L == 0:
            now_me = solve(L+1,R)
        else:
            now_me = solve(L+1,R) * live

    # 分岐
    if L == 0:
        now_make = 0
    else:
        now_make = solve(0,R-L) * P12

    now = now_me + now_make

    lis[L][R] = now % mod
    return lis[L][R]

print (solve(0,T) % mod)
0