結果

問題 No.1126 SUM
ユーザー anagohirameanagohirame
提出日時 2020-07-24 22:05:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 75 ms / 1,000 ms
コード長 501 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 86,852 KB
実行使用メモリ 77,936 KB
最終ジャッジ日時 2023-09-08 04:23:28
合計ジャッジ時間 3,244 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
77,828 KB
testcase_01 AC 75 ms
77,660 KB
testcase_02 AC 73 ms
77,540 KB
testcase_03 AC 74 ms
77,532 KB
testcase_04 AC 74 ms
77,716 KB
testcase_05 AC 74 ms
77,564 KB
testcase_06 AC 75 ms
77,628 KB
testcase_07 AC 73 ms
77,936 KB
testcase_08 AC 72 ms
77,540 KB
testcase_09 AC 74 ms
77,652 KB
testcase_10 AC 75 ms
77,476 KB
testcase_11 AC 74 ms
77,640 KB
testcase_12 AC 73 ms
77,624 KB
testcase_13 AC 74 ms
77,616 KB
testcase_14 AC 73 ms
77,580 KB
testcase_15 AC 71 ms
77,752 KB
testcase_16 AC 72 ms
77,680 KB
testcase_17 AC 72 ms
77,520 KB
testcase_18 AC 71 ms
77,724 KB
testcase_19 AC 73 ms
77,568 KB
testcase_20 AC 74 ms
77,480 KB
testcase_21 AC 74 ms
77,708 KB
testcase_22 AC 73 ms
77,620 KB
testcase_23 AC 72 ms
77,524 KB
testcase_24 AC 72 ms
77,756 KB
testcase_25 AC 72 ms
77,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10**9 + 7
list_size = 100002

f_list = [1] * list_size
f_r_list = [1] * list_size

for i in range(list_size-1):
	f_list[i+1] = (f_list[i] * (i+1)) % MOD

f_r_list[-1] = pow(f_list[-1], MOD - 2, MOD)

for i in range(list_size-2, -1, -1):
	f_r_list[i] = (f_r_list[i+1] * (i+1)) % MOD

def comb(n, r):
	if n < r or r < 0:
		return 0
	elif n == 0 or r == 0 or n == r:
		return 1
	else:
		return (f_list[n] * f_r_list[n-r] * f_r_list[r]) % MOD 

n, m = map(int, input().split())
print(comb(m+1, n+1))
0