結果

問題 No.1186 長方形の敷き詰め
ユーザー NatsubiSoganNatsubiSogan
提出日時 2020-08-02 17:37:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 962 ms / 2,000 ms
コード長 433 bytes
コンパイル時間 508 ms
コンパイル使用メモリ 87,184 KB
実行使用メモリ 91,856 KB
最終ジャッジ日時 2023-09-26 06:43:52
合計ジャッジ時間 10,888 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,148 KB
testcase_01 AC 68 ms
71,400 KB
testcase_02 AC 962 ms
91,716 KB
testcase_03 AC 72 ms
71,376 KB
testcase_04 AC 72 ms
71,364 KB
testcase_05 AC 70 ms
70,956 KB
testcase_06 AC 68 ms
71,452 KB
testcase_07 AC 69 ms
71,312 KB
testcase_08 AC 70 ms
71,200 KB
testcase_09 AC 70 ms
71,276 KB
testcase_10 AC 70 ms
71,368 KB
testcase_11 AC 78 ms
75,992 KB
testcase_12 AC 82 ms
76,080 KB
testcase_13 AC 76 ms
76,068 KB
testcase_14 AC 82 ms
76,128 KB
testcase_15 AC 78 ms
75,968 KB
testcase_16 AC 76 ms
76,016 KB
testcase_17 AC 354 ms
81,040 KB
testcase_18 AC 655 ms
86,308 KB
testcase_19 AC 763 ms
88,056 KB
testcase_20 AC 845 ms
89,552 KB
testcase_21 AC 616 ms
85,400 KB
testcase_22 AC 950 ms
91,856 KB
testcase_23 AC 571 ms
84,888 KB
testcase_24 AC 849 ms
89,508 KB
testcase_25 AC 554 ms
84,496 KB
testcase_26 AC 610 ms
85,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
def comb(n, r):
    if n < r:return 0
    if n < 0 or r < 0:return 0
    return fa[n] * fi[r] % mod * fi[n - r] % mod
n, m = map(int, input().split())
if n == 1:
    exit(print(1))
fa = [1] * (m + 1)
fi = [1] * (m + 1)
for i in range(1, m + 1):
    fa[i] = fa[i - 1] * i % mod
    fi[i] = pow(fa[i], mod - 2, mod)
ans = 0
for i in range(m // n + 1):
    ans += comb(m - i * (n - 1), i)
    ans %= mod
print(ans % mod)
0