結果

問題 No.398 ハーフパイプ(2)
ユーザー masamasa
提出日時 2016-07-19 02:12:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 988 bytes
コンパイル時間 2,350 ms
コンパイル使用メモリ 84,128 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-09 23:01:52
合計ジャッジ時間 1,921 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 26 ms
4,380 KB
testcase_03 AC 26 ms
4,380 KB
testcase_04 AC 26 ms
4,384 KB
testcase_05 AC 5 ms
4,380 KB
testcase_06 AC 4 ms
4,380 KB
testcase_07 AC 14 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 7 ms
4,380 KB
testcase_10 AC 6 ms
4,384 KB
testcase_11 AC 5 ms
4,380 KB
testcase_12 AC 15 ms
4,380 KB
testcase_13 AC 14 ms
4,380 KB
testcase_14 AC 16 ms
4,376 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 14 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>

using namespace std;

const int factorial[] = {1, 1, 2, 6, 24, 120, 720};

int calc(map<int, int> nums, int a, int f) {
	nums[a]++;
	nums[f]++;

	int prod = 1;
	for (auto p : nums) {
		prod *= factorial[p.second];
	}

	return factorial[6] / prod;
}

int main() {
	double x;
	cin >> x;
	int sum4 = x * 4;

	long long ans = 0;
	vector<int> tmp;
	for (int b = 0; b <= 100; b++) {
	for (int c = b; c <= 100; c++) {
	for (int d = c; d <= 100; d++) {
		int e = sum4 - (b + c + d);
		if (e < d || 100 < e) {
			continue;
		}

		map<int, int> nums;
		nums[b]++;
		nums[c]++;
		nums[d]++;
		nums[e]++;

		// a == b, f == e
		ans += calc(nums, b,   e)   * 1;
		// a == b, f != e
		ans += calc(nums, b,   e+1) * (100 - e);
		// a != b, f == e
		ans += calc(nums, b-1, e)   * b;
		// a != b, f != e
		ans += calc(nums, b-1, e+1) * b * (100 - e);

	}}}

	cout << ans << endl;
	return 0;
}
0