結果

問題 No.895 MESE
ユーザー tko919tko919
提出日時 2019-09-27 23:30:13
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 2,936 bytes
コンパイル時間 1,623 ms
コンパイル使用メモリ 173,136 KB
実行使用メモリ 5,728 KB
最終ジャッジ日時 2023-10-25 06:55:30
合計ジャッジ時間 3,770 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
5,728 KB
testcase_01 AC 17 ms
5,728 KB
testcase_02 AC 16 ms
5,728 KB
testcase_03 AC 16 ms
5,728 KB
testcase_04 AC 16 ms
5,728 KB
testcase_05 AC 16 ms
5,728 KB
testcase_06 AC 16 ms
5,728 KB
testcase_07 AC 16 ms
5,728 KB
testcase_08 AC 17 ms
5,728 KB
testcase_09 AC 16 ms
5,728 KB
testcase_10 AC 16 ms
5,728 KB
testcase_11 AC 16 ms
5,728 KB
testcase_12 AC 16 ms
5,728 KB
testcase_13 AC 30 ms
5,728 KB
testcase_14 AC 52 ms
5,728 KB
testcase_15 AC 54 ms
5,728 KB
testcase_16 AC 39 ms
5,728 KB
testcase_17 AC 21 ms
5,728 KB
testcase_18 AC 60 ms
5,728 KB
testcase_19 AC 59 ms
5,728 KB
testcase_20 AC 60 ms
5,728 KB
testcase_21 AC 60 ms
5,728 KB
testcase_22 AC 60 ms
5,728 KB
testcase_23 AC 60 ms
5,728 KB
testcase_24 AC 60 ms
5,728 KB
testcase_25 AC 60 ms
5,728 KB
testcase_26 AC 60 ms
5,728 KB
testcase_27 AC 60 ms
5,728 KB
testcase_28 AC 59 ms
5,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end

int mod = 1e9+7;
struct Mint {
    int val;
    Mint inv() const {
        int tmp, a = val, b = mod, x = 1, y = 0;
        while(b) tmp = a / b, a -= tmp * b, swap(a, b), x -= tmp * y, swap(x, y);
        return Mint(x);
    }
public:
    Mint() :val(0) {}
    Mint(ll x) :val(x >= 0 ? x % mod : x % mod + mod) {}
    int mtoi() { return this->val; }
    Mint pow(ll t) { Mint res = 1,b = *this; while(t){if(t&1)res *= b;b *= b;t >>= 1;}return res; }
    Mint& operator+=(const Mint& x) { if ((val += x.val) >= mod) val -= mod; return *this; }
    Mint& operator-=(const Mint& x) { if ((val += mod - x.val) >= mod) val -= mod; return *this; }
    Mint& operator*=(const Mint& x) { val = (ll)val * x.val % mod; return *this; }
    Mint& operator/=(const Mint& x) { return *this *= x.inv(); }
    bool operator==(const Mint& x) const { return val == x.val; }
    bool operator!=(const Mint& x) const { return val != x.val; }
    bool operator<(const Mint& x) const { return val < x.val; }
    bool operator<=(const Mint& x) const { return val <= x.val; }
    bool operator>(const Mint& x) const { return val > x.val; }
    bool operator>=(const Mint& x) const { return val >= x.val; }
    Mint operator+(const Mint& x) const { return Mint(*this) += x; }
    Mint operator-(const Mint& x) const { return Mint(*this) -= x; }
    Mint operator*(const Mint& x) const { return Mint(*this) *= x; }
    Mint operator/(const Mint& x) const { return Mint(*this) /= x; }
};
struct factorial {
    vector<Mint> Fact, Finv;
public:
    factorial(int maxx) {
        Fact.resize(maxx+1,Mint(1)),Finv.resize(maxx+1); rep(i,0,maxx)Fact[i+1]=Fact[i]*Mint(i+1);
        Finv[maxx]=Mint(1)/Fact[maxx]; rrep(i,maxx,0)Finv[i-1]=Finv[i]*Mint(i);
    }
    Mint fact(int n,bool inv) { if(inv) return Finv[n]; else return Fact[n]; }
    Mint nPr(int n,int r) { if(n<0||n<r||r<0) return Mint(0); else return Fact[n]*Finv[n-r]; }
    Mint nCr(int n,int r) { if(n<0||n<r||r<0) return Mint(0); else return Fact[n]*Finv[r]*Finv[n-r]; }
};

int main(){
    int a,b,c; scanf("%d%d%d",&a,&b,&c);
    int n=a+b+c;
    Mint ans,base=2; factorial fact(300010);
    rep(i,n-a-1,n-1){
        Mint add=fact.nCr(i-1,b-1)*fact.nCr(i-b,c-1),p=base.pow(i);
        p-=1; add*=p; ans+=add;
    }
    printf("%d\n",ans.mtoi());
    return 0;
}
0