結果

問題 No.2527 H and W
ユーザー lloyzlloyz
提出日時 2023-11-05 13:29:16
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 825 bytes
コンパイル時間 1,260 ms
コンパイル使用メモリ 81,880 KB
実行使用メモリ 83,520 KB
最終ジャッジ日時 2023-11-05 13:29:22
合計ジャッジ時間 4,823 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,612 KB
testcase_01 AC 37 ms
53,612 KB
testcase_02 AC 110 ms
83,232 KB
testcase_03 AC 37 ms
53,612 KB
testcase_04 AC 119 ms
83,488 KB
testcase_05 AC 118 ms
83,488 KB
testcase_06 AC 128 ms
83,520 KB
testcase_07 AC 37 ms
53,612 KB
testcase_08 AC 110 ms
83,232 KB
testcase_09 AC 103 ms
83,232 KB
testcase_10 AC 105 ms
83,232 KB
testcase_11 AC 137 ms
83,488 KB
testcase_12 AC 122 ms
83,496 KB
testcase_13 AC 119 ms
83,496 KB
testcase_14 AC 114 ms
83,496 KB
testcase_15 AC 115 ms
83,488 KB
testcase_16 AC 102 ms
83,232 KB
testcase_17 AC 120 ms
83,232 KB
testcase_18 AC 110 ms
83,232 KB
testcase_19 AC 81 ms
73,812 KB
testcase_20 AC 82 ms
75,996 KB
testcase_21 AC 103 ms
83,232 KB
testcase_22 AC 106 ms
83,232 KB
testcase_23 AC 107 ms
83,232 KB
testcase_24 AC 78 ms
74,964 KB
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

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 and 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