結果

問題 No.1126 SUM
ユーザー NewGardenNewGarden
提出日時 2020-07-24 22:22:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 1,000 ms
コード長 2,307 bytes
コンパイル時間 1,228 ms
コンパイル使用メモリ 120,312 KB
実行使用メモリ 5,472 KB
最終ジャッジ日時 2023-09-08 04:33:25
合計ジャッジ時間 2,453 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
5,272 KB
testcase_01 AC 5 ms
5,316 KB
testcase_02 AC 5 ms
5,380 KB
testcase_03 AC 5 ms
5,376 KB
testcase_04 AC 6 ms
5,436 KB
testcase_05 AC 5 ms
5,164 KB
testcase_06 AC 6 ms
5,196 KB
testcase_07 AC 5 ms
5,196 KB
testcase_08 AC 6 ms
5,448 KB
testcase_09 AC 6 ms
5,316 KB
testcase_10 AC 5 ms
5,200 KB
testcase_11 AC 5 ms
5,164 KB
testcase_12 AC 6 ms
5,256 KB
testcase_13 AC 6 ms
5,316 KB
testcase_14 AC 5 ms
5,380 KB
testcase_15 AC 5 ms
5,256 KB
testcase_16 AC 5 ms
5,152 KB
testcase_17 AC 6 ms
5,324 KB
testcase_18 AC 5 ms
5,252 KB
testcase_19 AC 5 ms
5,160 KB
testcase_20 AC 6 ms
5,316 KB
testcase_21 AC 5 ms
5,148 KB
testcase_22 AC 5 ms
5,376 KB
testcase_23 AC 6 ms
5,256 KB
testcase_24 AC 5 ms
5,472 KB
testcase_25 AC 6 ms
5,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(ll i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=100010;
const ll mod=1e9+7;

vector<ll> inv,fact,invfact;
void mod_build(int n){  
  fact.resize(n+1); inv.resize(n+1); invfact.resize(n+1);
  fact[0]=inv[0]=invfact[0]=1; inv[1]=1;
  rep(i,n){
    fact[i+1]=fact[i]*(i+1)%mod;
    if(i>0)inv[i+1]=mod-inv[mod%(i+1)]*(mod/(i+1))%mod;
    invfact[i+1]=invfact[i]*inv[i+1]%mod;
  }
}
ll perm(int n,int k){ if(n<0||k<0||k>n){ return 0; } else { return fact[n]*invfact[n-k]%mod; } }
ll comb(int n,int k){ if(n<0||k<0||k>n){ return 0; } else { return (fact[n]*invfact[n-k]%mod)*invfact[k]%mod; }}
ll modpow(ll x,ll n){
  x%=mod; ll res=1;
  while(n>0){ if(n&1){res=res*x%mod;} x=x*x%mod; n>>=1; }
  return res;
}
ll modinv(ll a){ return modpow(a, mod-2); }

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; }
    mint& operator-=(const mint a) { if ((x += mod-a.x) >= mod) x -= mod; return *this; }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { mint res(*this); return res+=a; }
    mint operator-(const mint a) const { mint res(*this); return res-=a; }
    mint operator*(const mint a) const { mint res(*this); return res*=a; }
    mint pow(ll t) const { if (!t) return 1; mint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; }
    // for prime mod
    mint inv() const { return pow(mod-2); }
    mint& operator/=(const mint a) { return (*this) *= a.inv(); }
    mint operator/(const mint a) const { mint res(*this); return res/=a; }
};


int main(){
  mod_build(mx);
  ll n,m;
  cin >> n >> m;
  mint ans = 0;
  REP(i,n,m+1){
    ans += comb(i,n);
  }
  cout << ans.x << ln;
  return 0;
}
0