結果

問題 No.398 ハーフパイプ(2)
ユーザー face4face4
提出日時 2019-12-12 20:55:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 1,621 bytes
コンパイル時間 781 ms
コンパイル使用メモリ 77,544 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-07 21:32:16
合計ジャッジ時間 1,739 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<map>
using namespace std;
typedef long long ll;

int main(){
    int fact[7];
    fact[0] = 1;
    for(int i = 1; i <= 6; i++) fact[i] = i*fact[i-1];
    double x;
    cin >> x;
    int n = (int)(x*4);
    ll ans = 0;
    for(int i = 0; i <= 100; i++){
        for(int j = i; j <= 100; j++){
            if(i+j > n) break;
            for(int k = j; k <= 100; k++){
                if(n-i-j-k < k) break;
                int l = n-i-j-k;
                if(l > 100) continue;
                int a = i, b = l;
                map<int,int> tmp;
                tmp[a]++;   tmp[i]++;
                tmp[j]++;   tmp[k]++;
                tmp[l]++;   tmp[b]++;
                ll add = fact[6];
                for(auto p : tmp)   add /= fact[p.second];
                ans += add;

                if(l != 100){
                    tmp[b]--;
                    add = fact[6];
                    for(auto p : tmp)   add /= fact[p.second];
                    ans += add*(100-l);
                    tmp[b]++;
                }
                if(i != 0){
                    tmp[a]--;
                    add = fact[6];
                    for(auto p : tmp)   add /= fact[p.second];
                    ans += add*i;
                    tmp[a]++;
                }

                if(i != 0 && l != 100){
                    tmp[i]--;
                    tmp[l]--;
                    add = fact[6];
                    for(auto p : tmp)   add /= fact[p.second];
                    ans += add*i*(100-l);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}
0