結果

問題 No.2527 H and W
ユーザー lloyzlloyz
提出日時 2023-11-05 13:37:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 163 ms / 2,000 ms
コード長 854 bytes
コンパイル時間 2,731 ms
コンパイル使用メモリ 81,640 KB
実行使用メモリ 85,468 KB
最終ジャッジ日時 2023-11-05 13:37:34
合計ジャッジ時間 9,938 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,540 KB
testcase_01 AC 40 ms
53,540 KB
testcase_02 AC 136 ms
83,148 KB
testcase_03 AC 48 ms
53,540 KB
testcase_04 AC 157 ms
83,404 KB
testcase_05 AC 115 ms
83,404 KB
testcase_06 AC 163 ms
85,468 KB
testcase_07 AC 40 ms
53,540 KB
testcase_08 AC 126 ms
83,148 KB
testcase_09 AC 100 ms
83,148 KB
testcase_10 AC 108 ms
83,148 KB
testcase_11 AC 116 ms
83,404 KB
testcase_12 AC 111 ms
83,412 KB
testcase_13 AC 142 ms
83,412 KB
testcase_14 AC 146 ms
83,412 KB
testcase_15 AC 152 ms
83,404 KB
testcase_16 AC 143 ms
83,148 KB
testcase_17 AC 128 ms
83,148 KB
testcase_18 AC 158 ms
83,148 KB
testcase_19 AC 107 ms
73,728 KB
testcase_20 AC 106 ms
75,912 KB
testcase_21 AC 149 ms
83,148 KB
testcase_22 AC 136 ms
83,148 KB
testcase_23 AC 145 ms
83,148 KB
testcase_24 AC 100 ms
74,880 KB
testcase_25 AC 130 ms
79,668 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

h, w, k = map(int, input().split())
mod = 998244353

max_ = max(h, w)
fact = [1] * (max_ + 1)
inv = [1] * (max_ + 1)
finv = [1] * (max_ + 1)
for i in range(2, max_ + 1):
    fact[i] = fact[i - 1] * i % mod
    inv[i] = mod - inv[mod % i] * (mod // i) % mod
    finv[i] = finv[i - 1] * inv[i] % mod
def comb(x, y):
    return fact[x] * finv[y] % mod * finv[x - y] % mod

f1 = 1
ans = 0
while f1 * f1 <= k:
    if k % f1 == 0:
        f2 = k // f1
        if f1 == f2:
            if f1 <= min(h, w):
                ans += comb(h, f2) * comb(w, f1) % mod
                ans %= mod
        else:
            if f2 <= h and f1 <= w:
                ans += comb(h, f2) * comb(w, f1) % mod
                ans %= mod
            if f2 <= w and f1 <= h:
                ans += comb(w, f2) * comb(h, f1) % mod
                ans %= mod
    f1 += 1
print(ans)
0