結果

問題 No.2527 H and W
ユーザー 👑 H20H20
提出日時 2023-11-23 21:56:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 312 ms / 2,000 ms
コード長 923 bytes
コンパイル時間 311 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 248,460 KB
最終ジャッジ日時 2023-11-23 21:56:37
合計ジャッジ時間 7,968 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,588 KB
testcase_01 AC 38 ms
53,588 KB
testcase_02 AC 286 ms
247,928 KB
testcase_03 AC 57 ms
53,588 KB
testcase_04 AC 294 ms
248,328 KB
testcase_05 AC 288 ms
248,328 KB
testcase_06 AC 293 ms
248,460 KB
testcase_07 AC 37 ms
53,588 KB
testcase_08 AC 294 ms
245,880 KB
testcase_09 AC 266 ms
245,880 KB
testcase_10 AC 264 ms
247,928 KB
testcase_11 AC 287 ms
248,328 KB
testcase_12 AC 312 ms
248,328 KB
testcase_13 AC 281 ms
248,328 KB
testcase_14 AC 278 ms
248,328 KB
testcase_15 AC 292 ms
248,328 KB
testcase_16 AC 273 ms
245,880 KB
testcase_17 AC 301 ms
247,928 KB
testcase_18 AC 268 ms
245,880 KB
testcase_19 AC 178 ms
188,976 KB
testcase_20 AC 188 ms
205,600 KB
testcase_21 AC 276 ms
245,880 KB
testcase_22 AC 268 ms
245,880 KB
testcase_23 AC 273 ms
245,880 KB
testcase_24 AC 189 ms
204,576 KB
testcase_25 AC 230 ms
244,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


p = 998244353
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

H,W,K = map(int,input().split())
mod = 998244353
D = make_divisors(K)

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

for i in range(2, max(W,H) + 1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[p % i] * (p // i)) % mod)
    factinv.append((factinv[-1] * inv[-1]) % mod)

ans = 0

for d in D:
    if d<=H and K//d<=W:
        ans = (ans + cmb(H,d,mod)*cmb(W,K//d,mod) ) % mod
print(ans)
0