結果

問題 No.2527 H and W
ユーザー ああいいああいい
提出日時 2023-11-11 20:58:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 640 bytes
コンパイル時間 332 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 77,636 KB
最終ジャッジ日時 2023-11-11 20:58:20
合計ジャッジ時間 4,028 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
75,136 KB
testcase_01 AC 63 ms
75,136 KB
testcase_02 AC 99 ms
75,520 KB
testcase_03 AC 63 ms
75,136 KB
testcase_04 AC 68 ms
75,264 KB
testcase_05 AC 67 ms
75,264 KB
testcase_06 AC 74 ms
77,636 KB
testcase_07 AC 63 ms
75,136 KB
testcase_08 AC 82 ms
75,520 KB
testcase_09 AC 63 ms
75,136 KB
testcase_10 AC 63 ms
75,136 KB
testcase_11 AC 71 ms
75,520 KB
testcase_12 AC 81 ms
77,636 KB
testcase_13 AC 81 ms
77,636 KB
testcase_14 AC 86 ms
77,636 KB
testcase_15 AC 72 ms
75,520 KB
testcase_16 AC 84 ms
75,520 KB
testcase_17 AC 91 ms
77,636 KB
testcase_18 AC 86 ms
77,636 KB
testcase_19 AC 79 ms
77,636 KB
testcase_20 AC 81 ms
77,636 KB
testcase_21 AC 88 ms
77,636 KB
testcase_22 AC 88 ms
77,636 KB
testcase_23 AC 88 ms
77,636 KB
testcase_24 AC 74 ms
75,520 KB
testcase_25 AC 66 ms
75,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H,W,K = map(int,input().split())
C = 10 ** 6 + 5

P = 998244353
fact = [1] * C
fact_inv = [1] * C
for i in range(2,C):
    fact[i] = fact[i-1] * i % P
fact_inv[-1] = pow(fact[-1],P - 2,P)
for i in range(C - 2,0,-1):
    fact_inv[i] = fact_inv[i + 1] * (i + 1)  % P
def comb(n,k):
    return fact[n] * fact_inv[k] % P * fact_inv[n - k] % P

#hW + wH - hw = HW - K
#w = (HW - K - hW) / (H - h)

ans = 0
import sys
if K == 0:
    print(1)
    exit()
for h in range(H):
    U = H * W - K - h * W
    if U < 0:continue
    V = H - h
    if U % V == 0:
        w = U // V
        ans += comb(H,h) * comb(W,w) % P
        ans %= P
print(ans)
    
0