結果
問題 |
No.1126 SUM
|
ユーザー |
|
提出日時 | 2021-09-19 15:50:34 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 33 ms / 1,000 ms |
コード長 | 1,399 bytes |
コンパイル時間 | 1,178 ms |
コンパイル使用メモリ | 82,884 KB |
実行使用メモリ | 6,656 KB |
最終ジャッジ日時 | 2024-07-01 19:10:20 |
合計ジャッジ時間 | 2,582 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 |
ソースコード
#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; }