結果

問題 No.1126 SUM
ユーザー logxlogx
提出日時 2020-07-26 22:15:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 41 ms / 1,000 ms
コード長 1,351 bytes
コンパイル時間 3,515 ms
コンパイル使用メモリ 167,756 KB
実行使用メモリ 4,648 KB
最終ジャッジ日時 2023-09-11 05:07:27
合計ジャッジ時間 3,618 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
4,380 KB
testcase_01 AC 39 ms
4,624 KB
testcase_02 AC 16 ms
4,380 KB
testcase_03 AC 12 ms
4,380 KB
testcase_04 AC 39 ms
4,520 KB
testcase_05 AC 32 ms
4,404 KB
testcase_06 AC 20 ms
4,376 KB
testcase_07 AC 29 ms
4,376 KB
testcase_08 AC 30 ms
4,380 KB
testcase_09 AC 34 ms
4,384 KB
testcase_10 AC 34 ms
4,416 KB
testcase_11 AC 27 ms
4,376 KB
testcase_12 AC 35 ms
4,380 KB
testcase_13 AC 20 ms
4,376 KB
testcase_14 AC 25 ms
4,376 KB
testcase_15 AC 21 ms
4,380 KB
testcase_16 AC 34 ms
4,376 KB
testcase_17 AC 20 ms
4,380 KB
testcase_18 AC 28 ms
4,376 KB
testcase_19 AC 38 ms
4,572 KB
testcase_20 AC 20 ms
4,380 KB
testcase_21 AC 37 ms
4,384 KB
testcase_22 AC 28 ms
4,376 KB
testcase_23 AC 36 ms
4,416 KB
testcase_24 AC 26 ms
4,380 KB
testcase_25 AC 41 ms
4,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
typedef long long ll;
typedef pair<int,int> p;
//const ll big=998244353;
const ll big=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    ll m,n;cin >> n >> m;
    vector<ll> fac(m+1),facin(m+1);
    fac[0]=1;
    facin[0]=1;
    rep(i,m){
        fac[i+1]=fac[i]*(i+1)%big;
        facin[i+1]=facin[i]*inv(i+1)%big;
    }
    ll ans=0;
    rep2(i,n,m+1){//com(i,n)
        ans+=fac[i]*facin[n]%big *facin[i-n]%big;
        ans%=big;
    }
    cout << ans << endl;
}
0