結果

問題 No.2527 H and W
ユーザー noriocnorioc
提出日時 2023-11-04 16:29:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 912 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 81,772 KB
実行使用メモリ 75,536 KB
最終ジャッジ日時 2023-11-04 16:29:32
合計ジャッジ時間 3,570 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,524 KB
testcase_01 AC 37 ms
53,524 KB
testcase_02 AC 104 ms
75,292 KB
testcase_03 AC 37 ms
53,524 KB
testcase_04 AC 37 ms
53,524 KB
testcase_05 AC 108 ms
75,292 KB
testcase_06 AC 108 ms
75,536 KB
testcase_07 AC 37 ms
53,524 KB
testcase_08 AC 104 ms
75,292 KB
testcase_09 AC 89 ms
74,904 KB
testcase_10 AC 89 ms
74,904 KB
testcase_11 AC 105 ms
75,292 KB
testcase_12 AC 106 ms
75,424 KB
testcase_13 AC 106 ms
75,424 KB
testcase_14 AC 106 ms
75,424 KB
testcase_15 AC 104 ms
75,292 KB
testcase_16 AC 104 ms
75,292 KB
testcase_17 AC 104 ms
75,292 KB
testcase_18 AC 105 ms
75,292 KB
testcase_19 AC 81 ms
69,012 KB
testcase_20 AC 86 ms
70,468 KB
testcase_21 AC 105 ms
75,424 KB
testcase_22 AC 131 ms
75,424 KB
testcase_23 AC 105 ms
75,424 KB
testcase_24 AC 81 ms
69,780 KB
testcase_25 AC 85 ms
72,972 KB
権限があれば一括ダウンロードができます

ソースコード

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):  # 塗らない行数を固定
    w = K // h  # h を決めると、K = h * w より横の列数が求まる
    if K != h * w or w > W: continue
    ans += comb(H, h) * comb(W, w)
    ans %= MOD

print(ans)
0