結果

問題 No.2527 H and W
ユーザー miya145592miya145592
提出日時 2023-11-03 22:21:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 431 ms / 2,000 ms
コード長 1,228 bytes
コンパイル時間 413 ms
コンパイル使用メモリ 81,864 KB
実行使用メモリ 249,476 KB
最終ジャッジ日時 2023-11-03 22:21:53
合計ジャッジ時間 8,756 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,672 KB
testcase_01 AC 40 ms
53,672 KB
testcase_02 AC 368 ms
249,476 KB
testcase_03 AC 35 ms
53,672 KB
testcase_04 AC 379 ms
249,476 KB
testcase_05 AC 403 ms
249,476 KB
testcase_06 AC 431 ms
249,476 KB
testcase_07 AC 37 ms
53,672 KB
testcase_08 AC 347 ms
249,476 KB
testcase_09 AC 371 ms
249,476 KB
testcase_10 AC 340 ms
249,476 KB
testcase_11 AC 358 ms
249,476 KB
testcase_12 AC 382 ms
249,476 KB
testcase_13 AC 352 ms
249,476 KB
testcase_14 AC 346 ms
249,476 KB
testcase_15 AC 384 ms
249,476 KB
testcase_16 AC 349 ms
249,476 KB
testcase_17 AC 344 ms
249,476 KB
testcase_18 AC 340 ms
249,476 KB
testcase_19 AC 252 ms
249,228 KB
testcase_20 AC 250 ms
249,228 KB
testcase_21 AC 342 ms
249,476 KB
testcase_22 AC 340 ms
249,476 KB
testcase_23 AC 366 ms
249,476 KB
testcase_24 AC 256 ms
249,228 KB
testcase_25 AC 294 ms
249,228 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]

def nPr(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    return g1[n] * g2[n-r] % mod

def nCr(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return (g1[n] * g2[r] % mod) * g2[n-r] % mod

import sys
input = sys.stdin.readline
MOD = 998244353
H, W, K = map(int, input().split())
N = max(H, W)

g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
fact = [1, 1]
fact_inv = [1, 1]

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % MOD )
    inverse.append( ( -inverse[MOD % i] * (MOD//i) ) % MOD )
    g2.append( (g2[-1] * inverse[-1]) % MOD )
    fact.append( (fact[-1] * i) % MOD )
    fact_inv.append(fact_inv[-1] * inverse[-1] % MOD)


D = make_divisors(K)
cnt = 0
for d in D:
    if d>H:
        break
    n = K//d
    if n>W:
        continue
    cnt += nCr(H, d, MOD) * nCr(W, n, MOD) % MOD
    cnt %= MOD
print(cnt)
0