結果

問題 No.1126 SUM
ユーザー yurujirouyurujirou
提出日時 2021-09-19 15:50:34
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 32 ms / 1,000 ms
コード長 1,399 bytes
コンパイル時間 855 ms
コンパイル使用メモリ 76,796 KB
実行使用メモリ 6,740 KB
最終ジャッジ日時 2023-09-14 11:42:57
合計ジャッジ時間 3,633 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
6,612 KB
testcase_01 AC 32 ms
6,428 KB
testcase_02 AC 32 ms
6,432 KB
testcase_03 AC 31 ms
6,608 KB
testcase_04 AC 32 ms
6,468 KB
testcase_05 AC 32 ms
6,484 KB
testcase_06 AC 31 ms
6,408 KB
testcase_07 AC 32 ms
6,584 KB
testcase_08 AC 32 ms
6,468 KB
testcase_09 AC 32 ms
6,448 KB
testcase_10 AC 32 ms
6,612 KB
testcase_11 AC 32 ms
6,436 KB
testcase_12 AC 32 ms
6,460 KB
testcase_13 AC 32 ms
6,432 KB
testcase_14 AC 32 ms
6,456 KB
testcase_15 AC 32 ms
6,460 KB
testcase_16 AC 32 ms
6,464 KB
testcase_17 AC 32 ms
6,556 KB
testcase_18 AC 32 ms
6,508 KB
testcase_19 AC 32 ms
6,428 KB
testcase_20 AC 32 ms
6,408 KB
testcase_21 AC 31 ms
6,740 KB
testcase_22 AC 31 ms
6,648 KB
testcase_23 AC 31 ms
6,428 KB
testcase_24 AC 32 ms
6,484 KB
testcase_25 AC 32 ms
6,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <stack>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <deque>
#include <functional>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>

//#include <atcoder/all>
//using namespace atcoder;

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define RREP(i,n) for(int i = (int)n-1; i >= 0; i--)
#define LREP(i,n) for(LL i = 0; i < (LL)n; i++)

#define Vi vector<int>
#define Vl vector<long long>
#define LP pair<long long ,long long>
#define P pair<int, int>
#define T3 tuple<LL, LL, LL>
#define T4 tuple<LL, LL, LL, LL>
#define INF 1000000007
#define SIZE	200010
#define MOD 1000000007
typedef long long LL;

LL inv_mod(LL x) {
	LL y = x, res = 1;
	REP(i, 32) {
		if ((MOD - 2) & ((LL)1 << i)) {
			res = (res * y) % MOD;
		}
		y = (y * y) % MOD;
	}
	return res;
}

LL N, M;
LL F[SIZE], FI[SIZE];
void init() {
	F[0] = FI[0] = 1;
	for (LL i = 1; i < SIZE; i++) {
		F[i] = (F[i - 1] * i) % MOD;
		FI[i] = (FI[i - 1] * inv_mod(i)) % MOD;
	}
}

LL comb(LL n, LL k) {
	LL res = F[n];
	res = (res * FI[n - k]) % MOD;
	res = (res * FI[k]) % MOD;
	return res;
}

int main() {
	init();
	cin >> N >> M;
	
	LL ans = 0;
	for (LL n = N; n <= M; n++) {
		ans = (ans + comb(n, N)) % MOD;
	}
	cout << ans << endl;
}
0