結果

問題 No.895 MESE
ユーザー 👑 jupirojupiro
提出日時 2020-01-27 04:01:00
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,546 bytes
コンパイル時間 761 ms
コンパイル使用メモリ 95,720 KB
実行使用メモリ 126,312 KB
最終ジャッジ日時 2023-10-12 12:43:05
合計ジャッジ時間 36,680 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 314 ms
126,000 KB
testcase_01 AC 314 ms
126,000 KB
testcase_02 AC 306 ms
125,992 KB
testcase_03 AC 312 ms
126,052 KB
testcase_04 AC 300 ms
126,048 KB
testcase_05 AC 302 ms
126,184 KB
testcase_06 AC 308 ms
125,992 KB
testcase_07 AC 295 ms
126,000 KB
testcase_08 AC 299 ms
126,020 KB
testcase_09 AC 310 ms
126,004 KB
testcase_10 AC 305 ms
126,012 KB
testcase_11 AC 312 ms
126,300 KB
testcase_12 AC 313 ms
126,000 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 TLE -
testcase_27 TLE -
testcase_28 TLE -
権限があれば一括ダウンロードができます

ソースコード

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[200000];
	mint sum[200000];
	t[0] = 1;
	mint res = 0;
	for (ll i = 1; i < 150000; i++) t[i] = t[i - 1] * 2;
	for (ll i = 0; i < 150000; 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