結果

問題 No.895 MESE
ユーザー alorie10alorie10
提出日時 2019-09-28 01:04:53
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 271 ms / 2,000 ms
コード長 778 bytes
コンパイル時間 736 ms
コンパイル使用メモリ 65,912 KB
実行使用メモリ 10,672 KB
最終ジャッジ日時 2023-10-25 08:59:32
合計ジャッジ時間 5,580 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,740 KB
testcase_01 AC 3 ms
7,740 KB
testcase_02 AC 3 ms
7,740 KB
testcase_03 AC 3 ms
7,740 KB
testcase_04 AC 2 ms
7,740 KB
testcase_05 AC 3 ms
7,740 KB
testcase_06 AC 2 ms
7,740 KB
testcase_07 AC 3 ms
7,740 KB
testcase_08 AC 4 ms
7,752 KB
testcase_09 AC 3 ms
7,748 KB
testcase_10 AC 5 ms
7,752 KB
testcase_11 AC 4 ms
7,756 KB
testcase_12 AC 4 ms
7,748 KB
testcase_13 AC 160 ms
10,456 KB
testcase_14 AC 156 ms
10,456 KB
testcase_15 AC 180 ms
10,456 KB
testcase_16 AC 149 ms
10,456 KB
testcase_17 AC 146 ms
10,456 KB
testcase_18 AC 270 ms
10,672 KB
testcase_19 AC 270 ms
10,672 KB
testcase_20 AC 270 ms
10,672 KB
testcase_21 AC 269 ms
10,672 KB
testcase_22 AC 270 ms
10,672 KB
testcase_23 AC 271 ms
10,672 KB
testcase_24 AC 270 ms
10,672 KB
testcase_25 AC 270 ms
10,672 KB
testcase_26 AC 270 ms
10,672 KB
testcase_27 AC 270 ms
10,672 KB
testcase_28 AC 271 ms
10,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
typedef long long ll;
ll n,a,b,c,s,ans,MOD=1e9+7,bi[300001],bi5[300001],L,w[300001];
ll f(ll x,ll y){
    if(y==0)return 1;
    if(y%2==0)return f(x,y/2)*f(x,y/2)%MOD;
    return x*f(x,y-1)%MOD;
}
ll comb(ll x,ll y){
    return bi[x]*bi5[x-y]%MOD*bi5[y]%MOD;
}
int main(void){
    cin>>a>>b>>c;
    s=a+b+c;
    bi[0]=1;
    bi5[0]=1;
    w[0]=1;
    for(int i=1;i<=s;i++){
        w[i]=w[i-1]*2%MOD;
        bi[i]=bi[i-1]*i%MOD;;
        bi5[i]=f(bi[i],1e9+5);
    }
    for(int i=2;i<=s-c;i++){
        L=comb(s-c-1,b);
        if(s-i-c>=b)L-=comb(s-i-c,b);
        ans+=L*w[s-i-1]%MOD*comb(s-i-1,c-1)%MOD;
        ans%=MOD;
        ans+=L*(w[s-i-1]-1)%MOD*comb(s-i-2,c-2)%MOD;
        ans%=MOD;
    }
    cout<<(ans+MOD)%MOD<<endl;
}
0