結果

問題 No.1186 長方形の敷き詰め
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-11-16 12:03:19
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,112 bytes
コンパイル時間 190 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 250,688 KB
最終ジャッジ日時 2023-11-16 12:03:24
合計ジャッジ時間 5,037 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
55,740 KB
testcase_01 AC 44 ms
55,740 KB
testcase_02 AC 312 ms
250,688 KB
testcase_03 AC 45 ms
55,740 KB
testcase_04 AC 45 ms
55,740 KB
testcase_05 AC 46 ms
55,740 KB
testcase_06 AC 44 ms
55,740 KB
testcase_07 AC 45 ms
55,740 KB
testcase_08 AC 45 ms
55,740 KB
testcase_09 AC 291 ms
250,688 KB
testcase_10 AC 58 ms
72,148 KB
testcase_11 AC 49 ms
63,828 KB
testcase_12 AC 50 ms
63,828 KB
testcase_13 AC 49 ms
63,828 KB
testcase_14 AC 51 ms
63,828 KB
testcase_15 AC 50 ms
63,828 KB
testcase_16 AC 50 ms
63,828 KB
testcase_17 AC 130 ms
134,564 KB
testcase_18 AC 208 ms
208,744 KB
testcase_19 AC 235 ms
227,840 KB
testcase_20 AC 260 ms
248,512 KB
testcase_21 AC 194 ms
193,144 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 292 ms
248,640 KB
testcase_25 AC 182 ms
178,616 KB
testcase_26 AC 196 ms
193,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline

N,M = map(int,input().split())

mod = 10**9 + 7
class combination():
    
    def __init__(self,N,p):
        
        
        self.fact = [1, 1]  # fact[n] = (n! mod p)
        self.factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
        self.inv = [0, 1]  # factinv 計算用
        self.p = p
        
        for i in range(2, N + 1):
            self.fact.append((self.fact[-1] * i) % p)
            self.inv.append((-self.inv[p % i] * (p // i)) % p)
            self.factinv.append((self.factinv[-1] * self.inv[-1]) % p)
        

    def cmb(self,n, r):
        if (r < 0) or (n < r):
            return 0
        r = min(r, n - r)
        return self.fact[n] * self.factinv[r] * self.factinv[n-r] % self.p
        
C = combination(M+1,mod)

if N>M:
    print(1)
    exit()
if N==1:
    print(1)
    exit()
ans = 1
cnt = 1
while M - N*cnt >=0 :
    
    ans += C.cmb(M-cnt*(N-1),cnt)
    # print(cnt,C.cmb(M-cnt*(N-1),cnt))
    ans %= mod
    cnt += 1
print(ans)
0