結果

問題 No.1126 SUM
ユーザー syunsukesyunsuke
提出日時 2020-07-25 00:13:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 111 ms / 1,000 ms
コード長 563 bytes
コンパイル時間 1,016 ms
コンパイル使用メモリ 86,520 KB
実行使用メモリ 95,364 KB
最終ジャッジ日時 2023-09-08 06:27:08
合計ジャッジ時間 5,223 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
94,976 KB
testcase_01 AC 103 ms
94,988 KB
testcase_02 AC 106 ms
94,884 KB
testcase_03 AC 98 ms
95,100 KB
testcase_04 AC 99 ms
95,108 KB
testcase_05 AC 101 ms
94,572 KB
testcase_06 AC 103 ms
95,128 KB
testcase_07 AC 109 ms
95,072 KB
testcase_08 AC 110 ms
95,180 KB
testcase_09 AC 108 ms
95,284 KB
testcase_10 AC 100 ms
94,880 KB
testcase_11 AC 111 ms
95,240 KB
testcase_12 AC 111 ms
94,992 KB
testcase_13 AC 107 ms
95,184 KB
testcase_14 AC 100 ms
95,164 KB
testcase_15 AC 101 ms
95,052 KB
testcase_16 AC 107 ms
95,160 KB
testcase_17 AC 98 ms
94,752 KB
testcase_18 AC 108 ms
95,296 KB
testcase_19 AC 101 ms
94,924 KB
testcase_20 AC 103 ms
95,056 KB
testcase_21 AC 99 ms
94,848 KB
testcase_22 AC 100 ms
94,880 KB
testcase_23 AC 110 ms
95,268 KB
testcase_24 AC 107 ms
95,364 KB
testcase_25 AC 98 ms
95,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

mod = 10**9+7 #出力の制限
N = 10**5+5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

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

N,M=map(int,input().split())
ans=0
for i in range(N,M+1):
    ans+=cmb(i,N,mod)
    ans%=mod
print(ans)
0