結果

問題 No.398 ハーフパイプ(2)
ユーザー T1610T1610
提出日時 2020-08-24 00:20:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 2,702 bytes
コンパイル時間 2,256 ms
コンパイル使用メモリ 205,272 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-23 18:43:23
合計ジャッジ時間 2,848 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

// #define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << " "
#define dumpL(x) cout << #x << " : " << x << '\n'
#define LINE cout << "line : " << __LINE__ << " "
#define LINEL cout << "line : " << __LINE__ << '\n'
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << " "
#define dumpVL(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) 
#define dumpL(x) 
#define LINE 
#define LINEL 
#define dumpV(v) 
#define dumpVL(v) 
#define STOP assert(false)
#endif


int main(){
    string s;
    cin >> s;
    int sum = 0;
    for(auto&& c: s) if(c != '.') {
        sum *= 10;
        sum += c - '0';
    }

    vi f(7);
    f[1] = 1;
    REP(i, 2, f.size()) f[i] = f[i-1] * i;

    sum *= 4;
    sum /= 100;
    ll ans = 0;
    rep(i0, 101) REP(i1, i0, 101) REP(i2, i1, 101) {
        int i3 = sum - (i0 + i1 + i2);
        if(i3 < i2 || i3 > 100) continue;
        vi v{i0, i1, i2, i3};
        dumpVL(v);
        map<int, int> mp;
        for(auto&& x: v) mp[x]++;
        //zenbutigau
        if(i0 > 0 && i3 < 100) {
            ll tmp = i0 * (100 - i3);
            tmp *= f[6];
            for(auto&& p: mp) tmp /= f[p.second];
            ans += tmp;
            dump(tmp);
        }
        // i3 dake issho
        if(i0 > 0) {
            ll tmp = i0;
            tmp *= f[6];
            mp[i3]++;
            for(auto&& p: mp) tmp /= f[p.second];
            mp[i3]--;
            ans += tmp;
            dump(tmp);
        }
        // i0 dake issho
        if(i3 < 100) {
            ll tmp = 100-i3;
            tmp *= f[6];
            mp[i0]++;
            for(auto&& p: mp) tmp /= f[p.second];
            mp[i0]--;
            ans += tmp;
            dump(tmp);
        }
        //i0 to i3
        {
            ll tmp = 1;
            tmp *= f[6];
            mp[i0]++;
            mp[i3]++;
            for(auto&& p: mp) tmp /= f[p.second];
            mp[i0]--;
            mp[i3]--;
            ans += tmp;
            dumpL(tmp);
        }
    }
    cout << ans << '\n';
    return 0;
}
0