結果

問題 No.1126 SUM
ユーザー yakkiyakki
提出日時 2020-07-24 22:28:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 1,000 ms
コード長 1,515 bytes
コンパイル時間 1,267 ms
コンパイル使用メモリ 119,304 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2023-09-08 04:41:59
合計ジャッジ時間 2,501 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
7,540 KB
testcase_01 AC 9 ms
7,588 KB
testcase_02 AC 8 ms
7,708 KB
testcase_03 AC 9 ms
7,792 KB
testcase_04 AC 9 ms
7,848 KB
testcase_05 AC 9 ms
7,548 KB
testcase_06 AC 9 ms
7,648 KB
testcase_07 AC 9 ms
7,668 KB
testcase_08 AC 9 ms
7,588 KB
testcase_09 AC 10 ms
7,644 KB
testcase_10 AC 8 ms
7,516 KB
testcase_11 AC 9 ms
7,540 KB
testcase_12 AC 10 ms
7,840 KB
testcase_13 AC 9 ms
7,516 KB
testcase_14 AC 8 ms
7,800 KB
testcase_15 AC 8 ms
7,752 KB
testcase_16 AC 9 ms
7,548 KB
testcase_17 AC 9 ms
7,736 KB
testcase_18 AC 10 ms
7,816 KB
testcase_19 AC 9 ms
7,800 KB
testcase_20 AC 8 ms
7,516 KB
testcase_21 AC 9 ms
7,592 KB
testcase_22 AC 8 ms
7,672 KB
testcase_23 AC 9 ms
7,684 KB
testcase_24 AC 9 ms
7,668 KB
testcase_25 AC 10 ms
7,708 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

struct Combination{
    vector<long long> _fac,_finv,_inv;
    const int m = MOD;

    Combination(int sz) : _fac(sz),_finv(sz),_inv(sz){
        _fac[0] = _fac[1] = 1;
        _finv[0] = _finv[1] = 1;
        _inv[1] = 1;
        for(int i = 2; i <= sz; i++){
            _fac[i] = _fac[i-1]*i%m;
            _inv[i] = m-_inv[m%i]*(m/i)%m;
            _finv[i] = _finv[i-1]*_inv[i]%m;
        }
    }

    inline long long fac(int n){return _fac[n];}
    inline long long inv(int n){return _inv[n];}
    inline long long finv(int n){return _finv[n];}

    long long comb(int n,int k){
        if(n < k) return 0;
        if(n < 0 || k < 0) return 0;
        return _fac[n]*(_finv[k]*_finv[n-k]%m)%m;
    }
};

int main(){
    Combination C(200000);
    int n,m; cin >> n >> m;
    ll ans = 0;
    repr(i,n,m+1){
        ans += C.comb(i,n);
        ans %= MOD;
    }
    cout << ans << endl;
}
0