結果

問題 No.2527 H and W
ユーザー norioc
提出日時 2023-11-04 00:38:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 831 bytes
コンパイル時間 263 ms
コンパイル使用メモリ 82,372 KB
実行使用メモリ 75,392 KB
最終ジャッジ日時 2024-09-25 21:43:53
合計ジャッジ時間 3,325 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

class Comb:
    def __init__(self, n, mod):
        fact = [0] * (n + 1)
        fact[0] = 1
        for i in range(1, n+1):
            fact[i] = i * fact[i-1] % mod

        ifact = [0] * (n + 1)
        ifact[n] = pow(fact[n], mod-2, mod)
        for i in range(n, 0, -1):
            ifact[i-1] = ifact[i] * i % mod
        self.fact = fact
        self.ifact = ifact
        self.mod = mod

    def __call__(self, n, k):
        if n < 0 or k > n: return 0
        return (self.fact[n] * self.ifact[k] % self.mod) * self.ifact[n-k] % self.mod


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

if K == H * W:
    print(1)
    exit()

comb = Comb(max(H, W), MOD)
ans = 0
for h in range(1, H+1):
    if K % h != 0: continue
    w = K // h
    if w > W: continue
    ans += comb(H, h) * comb(W, w)
    ans %= MOD

print(ans)
0