結果

問題 No.1126 SUM
ユーザー anagohirameanagohirame
提出日時 2020-07-24 22:06:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 262 ms / 1,000 ms
コード長 503 bytes
コンパイル時間 389 ms
コンパイル使用メモリ 87,236 KB
実行使用メモリ 232,512 KB
最終ジャッジ日時 2023-09-08 04:23:54
合計ジャッジ時間 8,359 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 255 ms
232,224 KB
testcase_01 AC 249 ms
232,352 KB
testcase_02 AC 250 ms
232,512 KB
testcase_03 AC 249 ms
232,336 KB
testcase_04 AC 253 ms
232,500 KB
testcase_05 AC 250 ms
232,440 KB
testcase_06 AC 249 ms
232,308 KB
testcase_07 AC 251 ms
232,328 KB
testcase_08 AC 249 ms
232,312 KB
testcase_09 AC 249 ms
232,308 KB
testcase_10 AC 254 ms
232,316 KB
testcase_11 AC 251 ms
232,372 KB
testcase_12 AC 254 ms
232,368 KB
testcase_13 AC 261 ms
232,264 KB
testcase_14 AC 251 ms
232,512 KB
testcase_15 AC 254 ms
232,376 KB
testcase_16 AC 257 ms
232,276 KB
testcase_17 AC 262 ms
232,372 KB
testcase_18 AC 259 ms
232,508 KB
testcase_19 AC 259 ms
232,308 KB
testcase_20 AC 249 ms
232,268 KB
testcase_21 AC 249 ms
232,452 KB
testcase_22 AC 250 ms
232,308 KB
testcase_23 AC 252 ms
232,272 KB
testcase_24 AC 249 ms
232,308 KB
testcase_25 AC 246 ms
232,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10**9 + 7
list_size = 10000002

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