結果

問題 No.1126 SUM
ユーザー mfbgjsczmfbgjscz
提出日時 2020-07-24 22:03:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 478 ms / 1,000 ms
コード長 1,798 bytes
コンパイル時間 2,043 ms
コンパイル使用メモリ 200,012 KB
実行使用メモリ 237,980 KB
最終ジャッジ日時 2023-09-08 04:23:45
合計ジャッジ時間 15,411 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 450 ms
237,836 KB
testcase_01 AC 459 ms
237,660 KB
testcase_02 AC 465 ms
237,768 KB
testcase_03 AC 455 ms
237,728 KB
testcase_04 AC 454 ms
237,808 KB
testcase_05 AC 455 ms
237,640 KB
testcase_06 AC 456 ms
237,732 KB
testcase_07 AC 456 ms
237,936 KB
testcase_08 AC 463 ms
237,696 KB
testcase_09 AC 469 ms
237,792 KB
testcase_10 AC 459 ms
237,656 KB
testcase_11 AC 455 ms
237,804 KB
testcase_12 AC 445 ms
237,660 KB
testcase_13 AC 451 ms
237,688 KB
testcase_14 AC 451 ms
237,692 KB
testcase_15 AC 441 ms
237,648 KB
testcase_16 AC 458 ms
237,644 KB
testcase_17 AC 463 ms
237,656 KB
testcase_18 AC 455 ms
237,808 KB
testcase_19 AC 470 ms
237,980 KB
testcase_20 AC 463 ms
237,724 KB
testcase_21 AC 468 ms
237,656 KB
testcase_22 AC 464 ms
237,776 KB
testcase_23 AC 472 ms
237,656 KB
testcase_24 AC 468 ms
237,640 KB
testcase_25 AC 478 ms
237,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
*/#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")    
using namespace std;
/*namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;
*/#define lli long long int
#define uli unsigned long long int
#define INF 9999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(50) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 10000010
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}
lli nCr(lli n, lli r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % mod) % mod;
}
int main(){
  long long N,M,sum=0;
  cin >> N >> M;
  COMinit();
  rep(i,N,M+1)sum=(sum+nCr(i,N))%mod;
  Out(sum);
}
0