結果

問題 No.1126 SUM
ユーザー kit84kit84
提出日時 2020-07-25 13:23:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 131 ms / 1,000 ms
コード長 882 bytes
コンパイル時間 424 ms
コンパイル使用メモリ 10,876 KB
実行使用メモリ 20,204 KB
最終ジャッジ日時 2023-09-09 10:53:14
合計ジャッジ時間 5,314 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
19,788 KB
testcase_01 AC 128 ms
19,708 KB
testcase_02 AC 126 ms
19,668 KB
testcase_03 AC 121 ms
19,664 KB
testcase_04 AC 122 ms
19,664 KB
testcase_05 AC 127 ms
19,864 KB
testcase_06 AC 123 ms
19,792 KB
testcase_07 AC 123 ms
19,660 KB
testcase_08 AC 121 ms
19,852 KB
testcase_09 AC 126 ms
19,788 KB
testcase_10 AC 128 ms
19,856 KB
testcase_11 AC 124 ms
19,852 KB
testcase_12 AC 128 ms
19,788 KB
testcase_13 AC 120 ms
19,848 KB
testcase_14 AC 122 ms
19,844 KB
testcase_15 AC 126 ms
19,836 KB
testcase_16 AC 122 ms
19,668 KB
testcase_17 AC 122 ms
19,704 KB
testcase_18 AC 121 ms
19,840 KB
testcase_19 AC 124 ms
19,664 KB
testcase_20 AC 129 ms
19,724 KB
testcase_21 AC 123 ms
19,668 KB
testcase_22 AC 121 ms
20,204 KB
testcase_23 AC 122 ms
19,780 KB
testcase_24 AC 122 ms
19,720 KB
testcase_25 AC 130 ms
19,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#import collections as col
input=sys.stdin.readline

def linput(ty=int, cvt=list):
	return cvt(map(ty,input().rstrip().split()))

def vinput(rep=1, ty=int, cvt=list):
	return cvt(ty(input().rstrip()) for _ in "*"*rep)

def facto(x, y, mod):
	re = 1
	for i in range(y, x+1):
		re *= i
		re %= mod
	#print(re, file=sys.stderr)
	return re

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    #return facto(n, n-r+1, mod) * g2[r] % mod
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
NN = 10**5+10
g1 = [1, 1] # factorial
g2 = [1, 1] # factorial^(-1)
inverse = [0, 1] # tmp

for i in range( 2, NN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


def main():
	A,B = linput()
	M = mod
	
	res = cmb(B+1, A+1, M)
	print(res)


main()
0