結果

問題 No.895 MESE
ユーザー roundplusroundplus
提出日時 2019-09-30 16:50:19
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 3,162 bytes
コンパイル時間 1,064 ms
コンパイル使用メモリ 105,352 KB
実行使用メモリ 12,664 KB
最終ジャッジ日時 2023-08-20 13:01:35
合計ジャッジ時間 2,085 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 15 ms
8,704 KB
testcase_14 AC 17 ms
8,620 KB
testcase_15 AC 20 ms
9,148 KB
testcase_16 AC 15 ms
8,100 KB
testcase_17 AC 12 ms
8,364 KB
testcase_18 AC 27 ms
12,560 KB
testcase_19 AC 26 ms
12,596 KB
testcase_20 AC 27 ms
12,596 KB
testcase_21 AC 27 ms
12,664 KB
testcase_22 AC 26 ms
12,636 KB
testcase_23 AC 26 ms
12,556 KB
testcase_24 AC 27 ms
12,576 KB
testcase_25 AC 27 ms
12,544 KB
testcase_26 AC 27 ms
12,528 KB
testcase_27 AC 27 ms
12,636 KB
testcase_28 AC 27 ms
12,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

typedef long long ll;
typedef long long int lli;
typedef pair<ll, ll> P;

ll MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

template<class T>
bool umax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(int arr[], int n) {
    int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


int dx[5] = {1, 0, -1, 0};
int dy[5] = {0, 1, 0, -1};

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};


class Combination{
    long long powmod(long long a, long long p){
        long long ans = 1LL;
        long long mul = a;
        while(p>0){
            if((p&1)==1) {
                ans = (ans * mul) % MOD;
            }
            mul=(mul*mul)%MOD;
            p>>=1;
        }
        return ans;
    }

public:
    long long N;
    long long mod;
    vector<long long> fact;
    vector<long long> revfact;

    Combination(long long n, long long m) : N(n), mod(m), fact(n+1), revfact(n+1){
        fact[0]=1;
        for(long long i=1; i<=N; i++){
            fact[i]=fact[i-1]*i;
            fact[i]%=mod;
        }

        revfact[N] = powmod(fact[N], mod-2);
        for(long long i=N-1; i>=0; i--){
            revfact[i]=revfact[i+1]*(i+1)%mod;
        }
    }

    long long getCombination(long a, long b){
        if(a<0 || b<0) return 0;
        if(b>a)return 0;
        return fact[a]*revfact[b]%mod*revfact[a-b]%mod;
    }
};

int main() {
    ll a, b, c; cin >> a >> b >> c;
    ll N=a+b+c;
    vector<ll> v(N+2, 0LL);
    Combination comb=Combination(N+2, MOD);


    vector<ll>mul2(N+1,1LL);
    for(ll i=1; i<N+1; i++){
        mul2[i]=mul2[i-1]*2;
        mul2[i]%=MOD;
    }

    ll ans=0LL;
    for(ll i=1; i<=a; i++){
        ans+=(comb.getCombination(N-i-2, c-1)*
            comb.getCombination(N-c-i-1, b-1) )
            %MOD*(mul2[N-(i+1)]-1)%MOD;
        ans%=MOD;
    }

    cout << ans << endl;
    return 0;
}
0