結果

問題 No.2802 Pill Bug in Grid Maze
ユーザー 寝癖
提出日時 2024-07-12 01:26:18
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 533 bytes
コンパイル時間 501 ms
コンパイル使用メモリ 82,476 KB
実行使用メモリ 84,700 KB
最終ジャッジ日時 2024-07-12 01:26:27
合計ジャッジ時間 8,656 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 29 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

H, W = map(int, input().split())
mod = 998244353

M = max(H, W) + 1
fact = [1] * M
inv = [1] * M
for i in range(1, M):
    fact[i] = fact[i - 1] * i % mod
    inv[i] = pow(fact[i], mod - 2, mod)

def comb(n, r):
    if not 0 <= r <= n:
        return 0
    return fact[n] * inv[r] % mod * inv[n - r] % mod

ans = 0
t = 1
k = 1
while t:
    if H*W-(H+W-1+k-1) < 0:
        break
    t = pow(2, H*W-(H+W-1+k-1), mod) * comb(W-1, k//2) * comb(H-2, (k-1)//2)
    if not t:
        break
    ans += t
    ans %= mod
    k += 1

print(ans)
0