結果

問題 No.108 トリプルカードコンプ
ユーザー chikkun0310chikkun0310
提出日時 2020-04-07 10:04:56
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 12 ms / 5,000 ms
コード長 1,484 bytes
コンパイル時間 1,625 ms
コンパイル使用メモリ 166,080 KB
実行使用メモリ 7,876 KB
最終ジャッジ日時 2023-09-21 17:16:01
合計ジャッジ時間 2,776 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll n;
double memo[101][101][101];
double hoge(ll i,ll j,ll k){
    if(i<0 || j<0 || k<0)return 0;
    if(i+j+k==0)return 0;
    if(memo[i][j][k]!=0)return memo[i][j][k];
    double ans=0;
    ans+=((hoge(i-1,j+1,k)+1)*(double)i);
    ans+=((hoge(i,j-1,k+1)+1)*(double)j);
    ans+=((hoge(i,j,k-1)+1)*(double)k);
    ans+=(double)(n-i-j-k);
    ans/=(double)(i+j+k);
    return memo[i][j][k]=ans;
}

int main(){fastio
    cin>>n;
    ll a[n];
    ll b[4];rep(i,0,3)b[i]=0;
    rep(i,0,n-1){
        cin>>a[i];
        if(a[i]>=3){
            b[3]++;
        }else{
            b[a[i]]++;
        }
    }
    double ans=hoge(b[0],b[1],b[2]);
    cout<<setprecision(12)<<ans<<endl;
    
    
    return 0;
}


0