結果

問題 No.398 ハーフパイプ(2)
ユーザー milanis48663220milanis48663220
提出日時 2020-07-01 01:00:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 1,640 bytes
コンパイル時間 1,096 ms
コンパイル使用メモリ 85,208 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-11 17:05:09
合計ジャッジ時間 1,930 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int X;
ll fac[7] = {1, 1, 2, 6, 24, 120, 720};

ll cnt(vector<int> v){
    ll ans = fac[6];
    int cnt = 1;
    int cur = v[0];
    for(int i = 1; i < 6; i++){
        if(cur != v[i]){
            ans /= fac[cnt];
            cnt = 1;
            cur = v[i];
        }else{
            cnt++;
        }
    }
    ans /= fac[cnt];
    // for(int i : v) cout << i << ' ';
    // cout << endl;
    // cout << ans << endl;
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    double x; cin >> x; x = x*4+0.01;
    X = (int)x;
    ll ans = 0;
    vector<int> v(6);
    for(ll l = 0; l <= 100; l++){
        for(ll r = l; r <= 100; r++){
            for(ll c = l; c <= r; c++){
                ll rem = X-(l+r+c);
                if( rem < c || rem > r) continue;
                // cout << l << ' '  << c << ' ' << rem << ' ' << r << endl;
                v[1] = l; v[2] = c; v[3] = rem; v[4] = r;
                // min < l && max > r
                v[0] = -1; v[5] = 101;
                ans += cnt(v)*l*(100-r);
                // min < l && max == r
                v[0] = -1; v[5] = r;
                ans += cnt(v)*l;
                // min == l && max > r
                v[0] = l; v[5] = 101;
                ans += cnt(v)*(100-r);
                // min == l && max == r
                v[0] = l; v[5] = r;
                ans += cnt(v);
            }
        }
    }
    cout << ans << endl;
}
0