結果

問題 No.398 ハーフパイプ(2)
ユーザー ctyl_0ctyl_0
提出日時 2016-07-16 00:01:57
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 2,529 bytes
コンパイル時間 1,045 ms
コンパイル使用メモリ 91,104 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-09 22:03:57
合計ジャッジ時間 2,089 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template
ll fact(int n){
    ll ret = 1;
    repd(i, 1, n + 1){
        ret *= i;
    }
    return ret;
}

ll comb(int n, int m){
    return fact(n) / fact(m) / fact(n - m);
}

int count(vector<int> cnt){
    int cur = 6;
    int perm = 1;
    rep(p, cnt.size()){
        perm *= comb(cur, cnt[p]);
        cur -= cnt[p];
    }
    return perm;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    double X;
    cin >> X;
    int Y = (int)(X * 4);
    ll sum = 0;
    rep(i, 101) repd(j, i, 101) repd(k, j, 101){
        int l = Y - i - j - k;
        if(k > l || l > 100) continue;
//        cout << i << ", " << j << ", " << k << ", " << l << endl;
        vector<int> nums = {i, j, k, l};
        vector<int> cnt = {1};
        
        repd(p, 1, nums.size()){
            if(nums[p] == nums[p - 1]) cnt.back()++;
            else cnt.pb(1);
        }
        int perm = 1;
        int cur = 4;
        rep(p, cnt.size()){
            perm *= comb(cur, cnt[p]);
            cur -= cnt[p];
        }
        
        if(i == l){
            int tmp = 0;
            tmp += i * (100 - i) * 30;
            tmp += i * 6;
            tmp += (100 - l) * 6;
            tmp += 1;
            sum += tmp;
            continue;
        }
        int tmp = 0;
        // 両端が同じ
        auto v = cnt;
        v.front()++, v.back()++;
//        output(count(v), 0);
        tmp += count(v);
        v = cnt;
        v.front()++, v.pb(1);
//        output(count(v) * (100 - l), 0);
        tmp += count(v) * (100 - l);
        v = cnt;
        v.back()++, v.pb(1);
//        output(count(v) * i, 0);
        tmp += count(v) * i;
        v = cnt;
        v.pb(1), v.pb(1);
//        output(count(v) * i * (100 - l), 0);
        tmp += count(v) * i * (100 - l);
        
        sum += tmp;
        
    }
    
    output(sum, 0);
    
    
    return 0;
}
0