結果

問題 No.895 MESE
ユーザー okok
提出日時 2019-09-27 23:15:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 1,766 bytes
コンパイル時間 755 ms
コンパイル使用メモリ 81,676 KB
実行使用メモリ 19,224 KB
最終ジャッジ日時 2023-10-25 06:19:32
合計ジャッジ時間 2,988 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

const int MAX_VAL = 1'000'000;

long long fac[MAX_VAL], mmi[MAX_VAL];

void factorial_mod(){
	 fac[0]=fac[1]=1;
	for(long long i = 2; i < MAX_VAL; fac[i]%=MOD,i++)
		fac[i] = fac[i-1]*(i%MOD);
}

long long power(long long x, long long n){
	long long ans = 1;
	for(;n;n>>=1,x*=x,ans%=MOD,x%=MOD)
		if(n&1)ans*=x;
	return ans%MOD;
}

void exgcd(int a, int b, int &x, int &y){
	if(b == 0){
		x = 1;
		y = 0;
		return ;
	}
	exgcd(b,a%b,y,x);
	y -= a/b * x;
}

void modular_multiplicatibe_inverse(){
	int x, y;  
	exgcd(fac[MAX_VAL-1],MOD,x,y);
	mmi[MAX_VAL-1] = x;
	for(long long i = MAX_VAL-2; i >= 0; mmi[i]%=MOD,i--)
		mmi[i] = mmi[i+1]*((i+1)%MOD);
}

long long combination(long long n, long long r){
	return n < r ? 0 :fac[n]*(mmi[r]*mmi[n-r]%MOD)%MOD;
}


signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int a, b, c;
	int sum = 0;
	int res = 0;
	
	factorial_mod();
	modular_multiplicatibe_inverse();
	
	cin>>a>>b>>c;
	
	for(int i = 1; i <= a+b+c-2; i++){
		sum = (sum + power(2,i-1))%MOD;
		// cout<<"i = "<<i<<" "<<sum<<endl;
		
		// cout<<a+b+c-i-1<<" > "<<a<<endl;
		
		if(a+b+c-i-1 > a) continue;
		
		// cout<<"<> "<<combination(i,c) * c %MOD * power(i,MOD-2) %MOD * sum % MOD<<endl;
		// cout<<"comb "<<combination(i,c)<<" "<<endl;
		res += combination(i,c) * c %MOD * power(i,MOD-2) %MOD * sum % MOD * combination(i-c,b-1)%MOD;
		
		res %= MOD;
	}
	
	cout<<res<<endl;
	
	return 0;
}
0