結果

問題 No.398 ハーフパイプ(2)
ユーザー tubo28tubo28
提出日時 2016-07-16 18:18:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 2,041 bytes
コンパイル時間 1,229 ms
コンパイル使用メモリ 117,772 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-09 22:11:50
合計ジャッジ時間 2,195 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
4,380 KB
testcase_01 AC 6 ms
4,384 KB
testcase_02 AC 39 ms
4,376 KB
testcase_03 AC 40 ms
4,380 KB
testcase_04 AC 40 ms
4,376 KB
testcase_05 AC 10 ms
4,376 KB
testcase_06 AC 8 ms
4,376 KB
testcase_07 AC 22 ms
4,380 KB
testcase_08 AC 6 ms
4,380 KB
testcase_09 AC 14 ms
4,384 KB
testcase_10 AC 12 ms
4,380 KB
testcase_11 AC 9 ms
4,376 KB
testcase_12 AC 24 ms
4,388 KB
testcase_13 AC 23 ms
4,380 KB
testcase_14 AC 27 ms
4,376 KB
testcase_15 AC 7 ms
4,380 KB
testcase_16 AC 23 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
using namespace std;
using ll = long long;
#define rep(i,k) for (int i = 0; i < (int)(k); i++)
#define all(c) begin(c), end(c)
#define int ll

int fac(int x) {
    return x == 0 ? 1 : x * fac(x - 1);
}

int count(vector<int> a) {
    map<int, int> c;
    assert(a.size() == 6);
    for (int i = 0; i < a.size(); i++) {
        ++c[a[i]];
    }
    int res = fac(6);
    for (auto &e : c) {
        res /= fac(e.second);
    }
    return res;
}

decltype(0) main() {
    double xx;

    while (cin >> xx) {
        int x = xx * 4 + 0.5;
        // OIESや埋め込みをせずに真面目にときます
        int ans = 0;
        for (int i = 0; i <= 100; i++) {
            for (int j = i; j <= 100; j++) {
                for (int k = j; k <= 100; k++) {
                    for (int l = k; l <= 100; l++) {
                        if (i + j + k + l == x) {
                            // 両端一致したりしなかったりを合わせるのが面倒くさい
                            ans += count({ 0,i,j,k,l,100 }) * i * (100 - l);
                            if (l != 100) ans += count({ i,i,j,k,l,100 }) * (100 - l);
                            if (i != 0) ans += count({ 0,i,j,k,l,l }) * i;
                            ans += count({ i,i,j,k,l,l });
                        }
                    }
                }
            }
        }
        cout << ans << endl;

    }
}
0