結果

問題 No.2527 H and W
コンテスト
ユーザー lloyz
提出日時 2023-11-05 13:29:16
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 825 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 123 ms
コンパイル使用メモリ 85,504 KB
実行使用メモリ 83,456 KB
最終ジャッジ日時 2026-04-13 01:44:34
合計ジャッジ時間 2,753 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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