結果

問題 No.940 ワープ ε=ε=ε=ε=ε=│;p>д<│
ユーザー square1001square1001
提出日時 2020-02-13 20:25:06
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,204 bytes
コンパイル時間 903 ms
コンパイル使用メモリ 78,608 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-15 23:19:48
合計ジャッジ時間 7,830 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#ifndef CLASS_MODINT
#define CLASS_MODINT

#include <cstdint>

template <std::uint32_t mod>
class modint {
private:
	std::uint32_t n;
public:
	modint() : n(0) {};
	modint(std::int64_t n_) : n((n_ >= 0 ? n_ : mod - (-n_) % mod) % mod) {};
	static constexpr std::uint32_t get_mod() { return mod; }
	std::uint32_t get() const { return n; }
	bool operator==(const modint& m) const { return n == m.n; }
	bool operator!=(const modint& m) const { return n != m.n; }
	modint& operator+=(const modint& m) { n += m.n; n = (n < mod ? n : n - mod); return *this; }
	modint& operator-=(const modint& m) { n += mod - m.n; n = (n < mod ? n : n - mod); return *this; }
	modint& operator*=(const modint& m) { n = std::uint64_t(n) * m.n % mod; return *this; }
	modint operator+(const modint& m) const { return modint(*this) += m; }
	modint operator-(const modint& m) const { return modint(*this) -= m; }
	modint operator*(const modint& m) const { return modint(*this) *= m; }
	modint inv() const { return (*this).pow(mod - 2); }
	modint pow(std::uint64_t b) const {
		modint ans = 1, m = modint(*this);
		while (b) {
			if (b & 1) ans *= m;
			m *= m;
			b >>= 1;
		}
		return ans;
	}
};

#endif // CLASS_MODINT

#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
using mint = modint<1000000007>;
int main() {
	int X, Y, Z;
	cin >> X >> Y >> Z;
	int lim = 2 * (X + Y + Z);
	vector<mint> fact(lim + 1), inv(lim + 1), factinv(lim + 1);
	fact[0] = 1; inv[1] = 1; factinv[0] = 1;
	for (int i = 1; i <= lim; ++i) fact[i] = fact[i - 1] * i;
	for (int i = 2; i <= lim; ++i) inv[i] = inv[mint::get_mod() % i] * mint(-int(mint::get_mod() / i));
	for (int i = 1; i <= lim; ++i) factinv[i] = factinv[i - 1] * inv[i];
	function<mint(int, int)> comb = [&](int x, int y) {
		if (y < 0 || x < y) return mint(0);
		return fact[x] * factinv[y] * factinv[x - y];
	};
	mint ans = 0;
	for (int i = 1; i <= X + Y + Z; ++i) {
		mint mul = comb(X + i - 1, X) * comb(Y + i - 1, Y) * comb(Z + i - 1, Z);
		for (int j = i; j <= X + Y + Z; ++j) {
			mint submul = comb(j, i);
			if ((j - i) % 2 == 0) ans += mul * submul;
			else ans -= mul * submul;
		}
	}
	cout << ans.get() << endl;
	return 0;
}
0