結果

問題 No.398 ハーフパイプ(2)
ユーザー 🍡yurahuna🍡yurahuna
提出日時 2016-07-15 23:57:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 1,809 bytes
コンパイル時間 2,583 ms
コンパイル使用メモリ 173,384 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-09 22:03:53
合計ジャッジ時間 2,758 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
typedef vector<vector<int>> Graph;
const int inf = 1e9;
const int mod = 1e9 + 7;

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

int perm(map<int, int> cnt, int x1, int x2) {
    if (x1 != -1) cnt[x1]++;
    if (x2 != -1) cnt[x2]++;
    int ret = fact[6];
    for (auto&& p : cnt) {
        ret /= fact[p.second];
    }
    // cout << ret << endl;
    return ret;
}

signed main() {
    // std::ios::sync_with_stdio(false);
    // std::cin.tie(0);

    double x;
    cin >> x;
    int sm = 4 * x;

    const int MAX = 100;
    int ans = 0;
    rep(a1, MAX + 1) {
        rep2(a2, a1, MAX + 1) {
            rep2(a3, a2, MAX + 1) {
                int a4 = sm - a1 - a2 - a3;
                if (!(a3 <= a4 && a4 <= MAX)) continue;
                // cout << a1 << " " << a2 << " " << a3 << " " << a4 << endl;
                map<int, int> cnt;
                cnt[a1]++;
                cnt[a2]++;
                cnt[a3]++;
                cnt[a4]++;
                if (a1 != 0 && a4 != MAX)   ans += perm(cnt, -1, -1) * a1 * (MAX - a4);
                if (a4 != MAX)              ans += perm(cnt, a1, -1) * (MAX - a4);
                if (a1 != 0)                ans += perm(cnt, a4, -1) * a1;
                ans += perm(cnt, a1, a4);
                // cout << ans << endl;
            }
        }
    }

    cout << ans << endl;

}
0