結果

問題 No.398 ハーフパイプ(2)
ユーザー kimiyukikimiyuki
提出日時 2016-07-15 23:00:18
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 1,161 bytes
コンパイル時間 456 ms
コンパイル使用メモリ 54,912 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-27 14:32:59
合計ジャッジ時間 1,321 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <map>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i,m,n) for (int i = (m); (i) < (n); ++(i))
typedef long long ll;
using namespace std;
int fact(int n) {
    return n == 0 ? 1 : n * fact(n-1);
}
int perm(int a, int b, int c, int d, int e, int f) {
    map<int,int> g;
    g[a] += 1;
    g[b] += 1;
    g[c] += 1;
    g[d] += 1;
    g[e] += 1;
    g[f] += 1;
    int acc = 1;
    for (auto it : g) acc *= fact(it.second);
    return acc;
}
int main() {
    float x; scanf("%f", &x);
    int y = 4*x;
    ll ans = 0;
    repeat (b,100+1) {
        repeat_from (c,b,100+1) {
            repeat_from (d,c,100+1) {
                int e = y-b-c-d;
                if (e < d or 100 < e) continue;
                ans += fact(6) / perm(b,   b, c, d, e, e);
                ans += fact(6) / perm(b,   b, c, d, e, e+1)                   * max(0, 100-(e+1)+1);
                ans += fact(6) / perm(b-1, b, c, d, e, e+1) * max(0, (b-1)+1) * max(0, 100-(e+1)+1);
                ans += fact(6) / perm(b-1, b, c, d, e, e)   * max(0, (b-1)+1);
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}
0