結果

問題 No.1126 SUM
ユーザー 双六双六
提出日時 2020-08-05 22:55:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 55 ms / 1,000 ms
コード長 946 bytes
コンパイル時間 1,057 ms
コンパイル使用メモリ 81,788 KB
実行使用メモリ 63,932 KB
最終ジャッジ日時 2023-10-17 22:50:58
合計ジャッジ時間 4,123 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
63,496 KB
testcase_01 AC 52 ms
63,836 KB
testcase_02 AC 47 ms
62,480 KB
testcase_03 AC 46 ms
62,252 KB
testcase_04 AC 55 ms
63,884 KB
testcase_05 AC 54 ms
63,420 KB
testcase_06 AC 51 ms
62,684 KB
testcase_07 AC 51 ms
63,248 KB
testcase_08 AC 50 ms
63,292 KB
testcase_09 AC 52 ms
63,512 KB
testcase_10 AC 52 ms
63,564 KB
testcase_11 AC 50 ms
63,116 KB
testcase_12 AC 52 ms
63,616 KB
testcase_13 AC 48 ms
62,692 KB
testcase_14 AC 49 ms
63,000 KB
testcase_15 AC 47 ms
62,784 KB
testcase_16 AC 51 ms
63,544 KB
testcase_17 AC 49 ms
62,708 KB
testcase_18 AC 51 ms
63,200 KB
testcase_19 AC 53 ms
63,780 KB
testcase_20 AC 48 ms
62,660 KB
testcase_21 AC 52 ms
63,740 KB
testcase_22 AC 51 ms
63,176 KB
testcase_23 AC 52 ms
63,668 KB
testcase_24 AC 50 ms
63,040 KB
testcase_25 AC 54 ms
63,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

class Combination(object):
	def __init__(self, N, con):
		self.fac = [0] * (N + 1)
		self.inv = [0] * (N + 1)
		self.finv = [0] * (N + 1)
		self.fac[0], self.fac[1] = 1, 1
		self.inv[1] = 1
		self.finv[0], self.finv[1] = 1, 1

		# 前計算
		for i in range(2, N + 1):
			self.fac[i] = self.fac[i - 1] * i % con
			self.inv[i] = self.inv[con % i] * (con - (con // i)) % con
			self.finv[i] = self.finv[i - 1] * self.inv[i] % con

	def com(self, N, k):
		return (self.fac[N] * self.finv[k] * self.finv[N - k]) % con

	def Catalan(self, k):
		return (fac[2 * k] * finv[k] * finv[k + 1]) % con

#処理内容
def main():
	N, M = getlist()
	C = Combination(M + 1, con)
	ans = C.com(M + 1, N + 1)
	print(ans)


if __name__ == '__main__':
	main()
0