結果

問題 No.2527 H and W
ユーザー playerplayer
提出日時 2023-12-24 19:02:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 403 ms / 2,000 ms
コード長 789 bytes
コンパイル時間 256 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 137,368 KB
最終ジャッジ日時 2023-12-24 19:02:44
合計ジャッジ時間 11,767 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 392 ms
137,240 KB
testcase_01 AC 356 ms
137,240 KB
testcase_02 AC 375 ms
137,368 KB
testcase_03 AC 386 ms
137,240 KB
testcase_04 AC 360 ms
137,240 KB
testcase_05 AC 359 ms
137,240 KB
testcase_06 AC 390 ms
137,368 KB
testcase_07 AC 352 ms
137,240 KB
testcase_08 AC 380 ms
137,368 KB
testcase_09 AC 383 ms
137,240 KB
testcase_10 AC 357 ms
137,240 KB
testcase_11 AC 358 ms
137,368 KB
testcase_12 AC 386 ms
137,368 KB
testcase_13 AC 372 ms
137,368 KB
testcase_14 AC 377 ms
137,368 KB
testcase_15 AC 374 ms
137,368 KB
testcase_16 AC 374 ms
137,368 KB
testcase_17 AC 374 ms
137,368 KB
testcase_18 AC 376 ms
137,368 KB
testcase_19 AC 403 ms
137,368 KB
testcase_20 AC 375 ms
137,368 KB
testcase_21 AC 372 ms
137,368 KB
testcase_22 AC 403 ms
137,368 KB
testcase_23 AC 369 ms
137,368 KB
testcase_24 AC 367 ms
137,368 KB
testcase_25 AC 386 ms
137,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

x = 10**6 + 1
mod = 998244353
fact = [None] * (x + 1)  # mod(n)での階乗
inv = [None] * (x + 1)  # mod(n)での逆元
fact_inv = [None] * (x + 1)  # mod(n)での階乗の逆元

fact[0] = fact[1] = 1
inv[1] = 1
fact_inv[0] = fact_inv[1] = 1

for i in range(2, x + 1):
    fact[i] = (fact[i - 1] * i) % mod
    inv[i] = (-inv[mod % i] * (mod // i)) % mod
    fact_inv[i] = (fact_inv[i - 1] * inv[i]) % mod


def comb(n, r):
    if r > n:
        return 0
    return (fact[n] * fact_inv[n - r] % mod) * fact_inv[r] % mod


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

red = h * w - k
ans = 0
for i in range(h + 1):
    if w * i > red:
        break
    num = red - w * i
    if num % (h - i) == 0:
        ww = num // (h - i)
        ans += comb(h, i) * comb(w, ww)
        ans %= mod

print(ans)
0