結果

問題 No.1186 長方形の敷き詰め
ユーザー NatsubiSoganNatsubiSogan
提出日時 2021-01-05 13:16:55
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,462 ms / 2,000 ms
コード長 1,268 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 167,680 KB
最終ジャッジ日時 2024-04-23 19:01:37
合計ジャッジ時間 10,456 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,880 KB
testcase_01 AC 30 ms
11,008 KB
testcase_02 AC 1,034 ms
167,680 KB
testcase_03 AC 31 ms
10,880 KB
testcase_04 AC 30 ms
10,880 KB
testcase_05 AC 30 ms
10,880 KB
testcase_06 AC 31 ms
10,880 KB
testcase_07 AC 30 ms
10,880 KB
testcase_08 AC 31 ms
10,880 KB
testcase_09 AC 30 ms
10,880 KB
testcase_10 AC 30 ms
10,880 KB
testcase_11 AC 32 ms
11,136 KB
testcase_12 AC 39 ms
11,904 KB
testcase_13 AC 31 ms
11,008 KB
testcase_14 AC 37 ms
11,776 KB
testcase_15 AC 32 ms
11,264 KB
testcase_16 AC 33 ms
11,008 KB
testcase_17 AC 345 ms
60,160 KB
testcase_18 AC 682 ms
112,896 KB
testcase_19 AC 804 ms
131,952 KB
testcase_20 AC 889 ms
146,680 KB
testcase_21 AC 634 ms
105,820 KB
testcase_22 AC 1,462 ms
167,652 KB
testcase_23 AC 585 ms
97,940 KB
testcase_24 AC 899 ms
147,244 KB
testcase_25 AC 574 ms
95,872 KB
testcase_26 AC 645 ms
106,692 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
class combinatorics:
    def __init__(self, n):
        self.n = n
        self.fa = [1] * (self.n * 2 + 1)
        self.fi = [1] * (self.n * 2 + 1)
        for i in range(1, self.n * 2 + 1):
            self.fa[i] = self.fa[i - 1] * i % mod
        self.fi[-1] = pow(self.fa[-1], mod - 2, mod)
        for i in range(self.n * 2, 0, -1):
            self.fi[i - 1] = self.fi[i] * i % mod
    def comb(self, n, r):
        if n < r:return 0
        if n < 0 or r < 0:return 0
        return self.fa[n] * self.fi[r] % mod * self.fi[n - r] % mod
    def perm(self, n, r):
        if n < r:return 0
        if n < 0 or r < 0:return 0
        return self.fa[n] * self.fi[n - r] % mod
    def combr(self, n, r):
        if n == r == 0:return 1
        return self.comb(n + r - 1, r)

#拡張Euclidの互除法
def extgcd(a, b, d = 0):
    g = a
    if b == 0:
        x, y = 1, 0
    else:
        x, y, g = extgcd(b, a % b)
        x, y = y, x - a // b * y
    return x, y, g

#mod p における逆元
def invmod(a, p):
    x, y, g = extgcd(a, p)
    x %= p
    return x

n, m = map(int, input().split())
if n == 1:exit(print(1))
ans = 0
C = combinatorics(m)
for i in range(m // n + 1):
    ans += C.comb(m - i * (n - 1), i)
    ans %= mod
print(ans % mod)
0