結果

問題 No.1126 SUM
ユーザー 夜
提出日時 2020-07-24 22:16:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 1,000 ms
コード長 1,003 bytes
コンパイル時間 718 ms
コンパイル使用メモリ 91,068 KB
実行使用メモリ 6,016 KB
最終ジャッジ日時 2023-09-08 04:30:01
合計ジャッジ時間 2,046 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
5,760 KB
testcase_01 AC 10 ms
5,764 KB
testcase_02 AC 10 ms
5,684 KB
testcase_03 AC 9 ms
5,848 KB
testcase_04 AC 10 ms
5,840 KB
testcase_05 AC 10 ms
5,708 KB
testcase_06 AC 10 ms
5,668 KB
testcase_07 AC 10 ms
5,764 KB
testcase_08 AC 10 ms
5,764 KB
testcase_09 AC 10 ms
5,676 KB
testcase_10 AC 9 ms
5,824 KB
testcase_11 AC 11 ms
5,748 KB
testcase_12 AC 10 ms
5,740 KB
testcase_13 AC 10 ms
5,852 KB
testcase_14 AC 9 ms
5,700 KB
testcase_15 AC 9 ms
5,704 KB
testcase_16 AC 10 ms
5,704 KB
testcase_17 AC 9 ms
5,700 KB
testcase_18 AC 10 ms
5,764 KB
testcase_19 AC 9 ms
5,824 KB
testcase_20 AC 9 ms
6,016 KB
testcase_21 AC 9 ms
5,700 KB
testcase_22 AC 9 ms
5,696 KB
testcase_23 AC 10 ms
5,708 KB
testcase_24 AC 10 ms
5,848 KB
testcase_25 AC 11 ms
5,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long fac[100010], finv[100010], inv[100010];
long long mod = 1000000007;
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < 100010; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
long long COM(long long n, long long k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int main() {
	long long n, m;
	cin >> n >> m;
	long long ans = 0;
	COMinit();
	for (int i = n; i <= m; i++) {
		ans += COM(i, n);
		ans %= 1000000007;
	}
	cout << ans << endl;
	return 0;
}
0