結果

問題 No.1126 SUM
ユーザー brthyyjpbrthyyjp
提出日時 2021-01-03 21:17:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 99 ms / 1,000 ms
コード長 461 bytes
コンパイル時間 515 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 92,416 KB
最終ジャッジ日時 2024-04-21 16:23:17
合計ジャッジ時間 3,789 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
91,136 KB
testcase_01 AC 87 ms
91,776 KB
testcase_02 AC 87 ms
91,008 KB
testcase_03 AC 84 ms
91,520 KB
testcase_04 AC 87 ms
91,964 KB
testcase_05 AC 85 ms
91,636 KB
testcase_06 AC 85 ms
91,648 KB
testcase_07 AC 89 ms
91,272 KB
testcase_08 AC 92 ms
90,984 KB
testcase_09 AC 90 ms
92,032 KB
testcase_10 AC 86 ms
92,416 KB
testcase_11 AC 95 ms
91,124 KB
testcase_12 AC 99 ms
91,080 KB
testcase_13 AC 92 ms
91,008 KB
testcase_14 AC 86 ms
91,392 KB
testcase_15 AC 85 ms
91,520 KB
testcase_16 AC 92 ms
92,032 KB
testcase_17 AC 85 ms
91,648 KB
testcase_18 AC 90 ms
91,264 KB
testcase_19 AC 88 ms
92,160 KB
testcase_20 AC 91 ms
91,044 KB
testcase_21 AC 85 ms
92,304 KB
testcase_22 AC 86 ms
91,264 KB
testcase_23 AC 94 ms
92,416 KB
testcase_24 AC 91 ms
91,264 KB
testcase_25 AC 83 ms
90,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = 10**6
mod = 10**9+7
fac = [1]*(N+1)
finv = [1]*(N+1)
for i in range(N):
    fac[i+1] = fac[i] * (i+1) % mod
finv[-1] = pow(fac[-1], mod-2, mod)
for i in reversed(range(N)):
    finv[i] = finv[i+1] * (i+1) % mod

def cmb1(n, r, mod):
    if r <0 or r > n:
        return 0
    r = min(r, n-r)
    return fac[n] * finv[r] * finv[n-r] % mod

n, m = map(int, input().split())
ans = 0
for i in range(n, m+1):
    ans += cmb1(i, n, mod)
    ans %= mod
print(ans)
0