結果

問題 No.398 ハーフパイプ(2)
ユーザー tossytossy
提出日時 2016-07-15 23:54:09
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 1,401 bytes
コンパイル時間 1,530 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-09 22:03:18
合計ジャッジ時間 1,741 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define INF 1<<30

int a[4];
// a[0]>=a[1]>=a[2]>=a[3]

long calc(){
    long res=0;

    long tmp=6*5*4*3*2*1;
    rep(i,4){
        int cnt=1;
        rep(j,3-i) if(a[i]==a[i+j+1]) cnt++;
        tmp /= cnt;
    }
    res += (100-a[0])*(a[3])*tmp;

    int cnt1=2;
    rep(i,3) if(a[i]==a[3]) cnt1++;
    res += (100-a[0])*tmp/cnt1;  // max==a[3]

    int cnt2=2;
    rep(i,3) if(a[i+1]==a[0]) cnt2++;
    res += (a[3])*tmp/cnt2;  //min==a[0]

    if(a[0]==a[3]) res+=1;
    else res += tmp/cnt1/cnt2;

    return res;
}

long dfs(int n, int idx){
    if(idx==4){
        if(n==0)return calc();
        else return 0;
    }

    long res=0;
    for(int i=min(n,100); i>=n/4; i--){
        if(idx>0 && i>a[idx-1]) i=a[idx-1];
        a[idx]=i;
        res += dfs(n-i, idx+1);
    }
    return res;
}

int main(){
    double x;
    cin>>x;
    int n = (int)(x*4.);

    long res = dfs(n, 0);

    cout<<res<<endl;

    return 0;
}
0