結果

問題 No.895 MESE
ユーザー tempura_pptempura_pp
提出日時 2019-09-27 21:47:06
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 1,796 bytes
コンパイル時間 1,015 ms
コンパイル使用メモリ 100,820 KB
実行使用メモリ 32,168 KB
最終ジャッジ日時 2023-10-25 03:18:21
合計ジャッジ時間 4,072 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
32,168 KB
testcase_01 AC 54 ms
32,168 KB
testcase_02 AC 54 ms
32,168 KB
testcase_03 AC 50 ms
32,168 KB
testcase_04 AC 56 ms
32,168 KB
testcase_05 AC 51 ms
32,168 KB
testcase_06 AC 58 ms
32,168 KB
testcase_07 AC 51 ms
32,168 KB
testcase_08 AC 49 ms
32,168 KB
testcase_09 AC 49 ms
32,168 KB
testcase_10 AC 52 ms
32,168 KB
testcase_11 AC 57 ms
32,168 KB
testcase_12 AC 48 ms
32,168 KB
testcase_13 AC 72 ms
32,168 KB
testcase_14 AC 69 ms
32,168 KB
testcase_15 AC 74 ms
32,168 KB
testcase_16 AC 66 ms
32,168 KB
testcase_17 AC 71 ms
32,168 KB
testcase_18 AC 81 ms
32,168 KB
testcase_19 AC 88 ms
32,168 KB
testcase_20 AC 83 ms
32,168 KB
testcase_21 AC 80 ms
32,168 KB
testcase_22 AC 83 ms
32,168 KB
testcase_23 AC 95 ms
32,168 KB
testcase_24 AC 89 ms
32,168 KB
testcase_25 AC 93 ms
32,168 KB
testcase_26 AC 93 ms
32,168 KB
testcase_27 AC 94 ms
32,168 KB
testcase_28 AC 92 ms
32,168 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;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
vector<ll> inv,fact,invfact;
void mod_build(int n=101010){
    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;
    return fact[n]*invfact[n-k]%mod;
}
ll comb(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return (fact[n]*invfact[n-k]%mod)*invfact[k]%mod;
}
ll powmod(ll n,ll k){
    k%=mod-1;
    if(k<0)k+=mod-1;
    ll ret=1;
    while(k){
        if(k&1)ret=ret*n%mod;
        n=n*n%mod;
        k>>=1;
    }
    return ret;
}
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    mod_build(1234567);
    ll X = comb(a+b+c-1,a-1) * comb(b+c-1,b-1)%mod * powmod(2,a+b+c-1)%mod;
    X += comb(a+b+c-2,a-2) * comb(b+c-1,b-1)%mod * (powmod(2,a+b+c-1)-1)%mod;
    X%=mod;
    cerr<<X<<endl;
    ll Y = 0;
    rep(i,a+b+c-1){
        Y += comb(i,c)*comb(i-c,b-1)%mod*powmod(2,i)%mod;
        Y += comb(i-1,c)*comb(i-1-c,b-2)%mod*(powmod(2,i)-1)%mod;
    }
    Y %= mod;
    cerr<<Y<<endl;
    ll sum = comb(a+b+c-1,a-1) * comb(b+c-1,b-1)%mod * (powmod(2,a+b+c)-1)%mod;
    cerr<<sum<<endl;
    cout<<(sum-X-Y+2*mod)%mod<<endl;
    return 0;
}
0