結果

問題 No.1388 Less than K
ユーザー MitarushiMitarushi
提出日時 2020-11-23 08:28:26
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,304 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 82,688 KB
実行使用メモリ 91,904 KB
最終ジャッジ日時 2024-05-04 17:33:03
合計ジャッジ時間 11,134 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 52 ms
79,360 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 55 ms
78,720 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 RE -
testcase_27 WA -
testcase_28 RE -
testcase_29 RE -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 RE -
testcase_47 RE -
testcase_48 RE -
testcase_49 RE -
testcase_50 RE -
testcase_51 RE -
testcase_52 RE -
testcase_53 RE -
testcase_54 RE -
testcase_55 RE -
testcase_56 RE -
testcase_57 RE -
testcase_58 RE -
testcase_59 RE -
testcase_60 RE -
testcase_61 RE -
testcase_62 RE -
testcase_63 RE -
testcase_64 RE -
testcase_65 RE -
testcase_66 RE -
testcase_67 RE -
testcase_68 RE -
testcase_69 RE -
testcase_70 RE -
testcase_71 RE -
testcase_72 RE -
testcase_73 RE -
testcase_74 RE -
testcase_75 RE -
testcase_76 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353

max_fact = 2*10**5 + 10
fact = [1]
for i in range(1, max_fact):
    fact.append(fact[-1] * i % mod)
fact_inv = [0] * max_fact
fact_inv[-1] = pow(fact[-1], mod - 2, mod)
for i in reversed(range(1, max_fact)):
    fact_inv[i - 1] = fact_inv[i] * i % mod


def comb(a, b):
    if a < 0 or b < 0:
        return 0
    elif a < b:
        return 0
    return fact[a] * fact_inv[b] % mod * fact_inv[a - b] % mod


h, w, k = map(int, input().split())
n = min(h, w)
ans = 0
if k > 300:
    k2 = (k + 2) // 2

    for i in range(n):
        s = comb(2*i, i)
        j = 1
        while i - j * k2 >= 0:
            if j % 2 == 0:
                s += comb(2*i,  i - j * k2) * 2
            else:
                s -= comb(2*i,  i - j * k2) * 2
            j += 1
        ans += s * comb(h+w-2, h-1-i) * comb(w+i-1, w-i-1)
        ans %= mod

else:
    k2 = k // 2
    dp1 = [0] * (k2 * 2 + 1)
    dp1[k2] = 1
    for i in range(n):
        dp2 = [0] * (k2 * 2 + 1)
        for j in range(k2 * 2 + 1):
            if j != 0:
                dp2[j] += dp2[j-1]
            if i != 0 and j != k2 * 2:
                dp2[j] += dp1[j+1]
            dp2[j] %= mod
        dp1 = dp2

    for i in range(n):
        ans += dp1[k2] * comb(h+w-2, h-1-i) * comb(w+i-1, w-i-1)
        ans %= mod
print(ans)
0