結果

問題 No.1186 長方形の敷き詰め
ユーザー NatsubiSoganNatsubiSogan
提出日時 2021-01-05 13:15:26
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,264 bytes
コンパイル時間 181 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 91,520 KB
最終ジャッジ日時 2024-04-23 19:01:02
合計ジャッジ時間 2,435 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,224 KB
testcase_01 AC 38 ms
52,224 KB
testcase_02 AC 83 ms
90,112 KB
testcase_03 AC 37 ms
52,456 KB
testcase_04 AC 36 ms
52,352 KB
testcase_05 AC 35 ms
52,480 KB
testcase_06 AC 35 ms
52,096 KB
testcase_07 AC 35 ms
52,352 KB
testcase_08 AC 35 ms
52,608 KB
testcase_09 AC 35 ms
52,480 KB
testcase_10 AC 39 ms
52,480 KB
testcase_11 AC 40 ms
59,008 KB
testcase_12 AC 41 ms
58,624 KB
testcase_13 AC 40 ms
58,752 KB
testcase_14 AC 40 ms
58,496 KB
testcase_15 AC 41 ms
58,496 KB
testcase_16 AC 42 ms
58,368 KB
testcase_17 AC 56 ms
68,224 KB
testcase_18 AC 70 ms
78,464 KB
testcase_19 AC 74 ms
83,072 KB
testcase_20 AC 77 ms
85,504 KB
testcase_21 AC 66 ms
77,440 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 78 ms
85,760 KB
testcase_25 AC 65 ms
75,136 KB
testcase_26 AC 68 ms
77,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 10 ** 9 + 7
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)
0