結果

問題 No.895 MESE
ユーザー leaf_1415leaf_1415
提出日時 2019-09-27 21:58:09
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,630 bytes
コンパイル時間 515 ms
コンパイル使用メモリ 62,484 KB
実行使用メモリ 12,992 KB
最終ジャッジ日時 2023-10-24 18:07:39
合計ジャッジ時間 1,796 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#define llint long long
#define mod 1000000007

using namespace std;

const int FACT_MAX = 300005;
llint fact[FACT_MAX], fact_inv[FACT_MAX];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < FACT_MAX; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	fact_inv[FACT_MAX-1] = modpow(fact[FACT_MAX-1], mod-2);
	for(int i = FACT_MAX-2; i >= 0; i--){
		fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
	}
}

llint comb(llint n, llint k)
{
	if(n == -1) return 1;
	llint ret = 1;
	ret *= fact[n];
	ret *= fact_inv[k], ret %= mod;
	ret *= fact_inv[n-k], ret %= mod;
	return ret;
}

llint a, b, c;
llint beki[300005], sum[300005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	make_fact();
	
	cin >> a >> b >> c;
	int n = a+b+c;
	
	beki[0] = 1;
	for(int i = 1; i <= n; i++) beki[i] = beki[i-1] * 2, beki[i] %= mod;
	sum[0] = beki[0];
	for(int i = 1; i <= n; i++) sum[i] = sum[i-1] + beki[i], sum[i] %= mod;
	
	llint ans = 0;
	for(int i = c-1; i < n-2; i++){
		llint tmp = 0;
		if(c >= 2 && i >= 1) tmp += comb(i-1, c-2) * sum[i-1] % mod, tmp %= mod;
		tmp += comb(i, c-1) * beki[i] % mod, tmp %= mod;
		llint mul = comb(a+b, a);
		if(i-(c-1)>= a) mul += mod - comb(i-(c-1), a), mul %= mod;
		if(i-(c-1)>= b) mul += mod - comb(i-(c-1), b), mul %= mod;
		tmp *= mul, tmp %= mod;
		ans += tmp, ans %= mod;
	}
	ans *= modpow(2, mod-2), ans %= mod;
	cout << ans << endl;
	
	return 0;
}
0