結果

問題 No.398 ハーフパイプ(2)
ユーザー kimiyukikimiyuki
提出日時 2016-07-15 23:00:18
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 1,161 bytes
コンパイル時間 500 ms
コンパイル使用メモリ 54,508 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-09 22:01:15
合計ジャッジ時間 1,334 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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