結果
| 問題 |
No.398 ハーフパイプ(2)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-07-19 02:12:17 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 28 ms / 2,000 ms |
| コード長 | 988 bytes |
| コンパイル時間 | 798 ms |
| コンパイル使用メモリ | 84,348 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-27 15:30:52 |
| 合計ジャッジ時間 | 1,609 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
ソースコード
#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;
}