結果

問題 No.895 MESE
ユーザー 👑 jupirojupiro
提出日時 2020-01-27 04:04:11
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 300 ms / 2,000 ms
コード長 2,546 bytes
コンパイル時間 915 ms
コンパイル使用メモリ 95,680 KB
実行使用メモリ 130,972 KB
最終ジャッジ日時 2023-10-12 12:44:56
合計ジャッジ時間 10,756 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 282 ms
130,680 KB
testcase_01 AC 278 ms
130,808 KB
testcase_02 AC 296 ms
130,804 KB
testcase_03 AC 281 ms
130,672 KB
testcase_04 AC 282 ms
130,736 KB
testcase_05 AC 279 ms
130,740 KB
testcase_06 AC 290 ms
130,972 KB
testcase_07 AC 276 ms
130,680 KB
testcase_08 AC 291 ms
130,788 KB
testcase_09 AC 274 ms
130,868 KB
testcase_10 AC 265 ms
130,680 KB
testcase_11 AC 270 ms
130,680 KB
testcase_12 AC 283 ms
130,748 KB
testcase_13 AC 284 ms
130,680 KB
testcase_14 AC 284 ms
130,716 KB
testcase_15 AC 289 ms
130,728 KB
testcase_16 AC 269 ms
130,736 KB
testcase_17 AC 253 ms
130,692 KB
testcase_18 AC 278 ms
130,716 KB
testcase_19 AC 268 ms
130,876 KB
testcase_20 AC 286 ms
130,688 KB
testcase_21 AC 285 ms
130,736 KB
testcase_22 AC 288 ms
130,876 KB
testcase_23 AC 287 ms
130,856 KB
testcase_24 AC 300 ms
130,972 KB
testcase_25 AC 284 ms
130,820 KB
testcase_26 AC 281 ms
130,688 KB
testcase_27 AC 279 ms
130,732 KB
testcase_28 AC 257 ms
130,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>


template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long mod = 1'000'000'007LL;
//const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};


long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

mint COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return mint(fac[n] * (finv[k] * finv[n - k] % mod) % mod);
}


int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	COMinit();
	ll a, b, c; cin >> a >> b >> c;
	ll n = a + b + c;
	mint t[500000];
	mint sum[500000];
	t[0] = 1;
	mint res = 0;
	for (ll i = 1; i < 450000; i++) t[i] = t[i - 1] * 2;
	for (ll i = 0; i < 450000; i++) sum[i + 1] = sum[i] + t[i];
	for (ll i = 1; n - i - 1 >= c && i <= a; i++) {
		res += COM(n - i - 2, c - 1) * COM(n - i - 1 - c, b - 1) * sum[n - i - 1];
	}
	cout << res.x << endl;
	return 0;

}

0