結果

問題 No.520 プロジェクトオイラーへの招待
ユーザー pekempeypekempey
提出日時 2017-05-28 23:05:15
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 4,000 ms
コード長 1,422 bytes
コンパイル時間 703 ms
コンパイル使用メモリ 72,228 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 14:32:23
合計ジャッジ時間 1,221 ms
ジャッジサーバーID
(参考情報)
judge14 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,348 KB
testcase_01 AC 3 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 3 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

constexpr int MOD = 1e9 + 7;

struct modint {
	int n;
	modint(int n = 0) : n(n) {}
};

modint operator+(modint a, modint b) { return modint((a.n += b.n) >= MOD ? a.n - MOD : a.n); }
modint operator-(modint a, modint b) { return modint((a.n -= b.n) < 0 ? a.n + MOD : a.n); }
modint operator*(modint a, modint b) { return modint(1LL * a.n * b.n % MOD); }
modint &operator+=(modint &a, modint b) { return a = a + b; }
modint &operator-=(modint &a, modint b) { return a = a - b; }
modint &operator*=(modint &a, modint b) { return a = a * b; }

int main() {
	int n;
	std::cin >> n;

	static modint dp[345][345];
	dp[1][1] = 1;
	for (int i = 0; i < 300; i++) {
		for (int j = 0; j < 300; j++) {
			dp[i + 1][j] += dp[i][j];
			dp[i][j + 1] += dp[i][j];
		}
	}

	while (n--) {
		int a, b, c;
		std::cin >> a >> b >> c;

		modint ans;
		for (int i = 1; i <= b; i++) {
			for (int j = 1; j <= c; j++) {
				ans += dp[a][i + j] * dp[b - i + 1][c - j + 1];
			}
		}

		for (int i = 1; i <= a; i++) {
			for (int j = i; j <= a; j++) {
				ans += dp[b][i] * dp[c][a - j + 1];
			}
		}
		for (int i = 1; i <= b; i++) {
			for (int j = i; j <= b; j++) {
				ans += dp[a][i] * dp[c][b - j + 1];
			}
		}
		for (int i = 1; i <= c; i++) {
			for (int j = i; j <= c; j++) {
				ans += dp[a][i] * dp[b][c - j + 1];
			}
		}
		std::cout << ans.n << std::endl;
	}
}
0