結果

問題 No.108 トリプルカードコンプ
ユーザー bonntanname0316
提出日時 2020-06-02 18:42:34
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 1,163 bytes
コンパイル時間 1,543 ms
コンパイル使用メモリ 168,676 KB
実行使用メモリ 23,040 KB
最終ジャッジ日時 2024-11-24 06:57:28
合計ジャッジ時間 54,271 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12 TLE * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod


double dp[101][101][101];
ll N;
ll A,B,C;
double Solve(ll a, ll b, ll c){
    if(dp[a][b][c]>-1) return dp[a][b][c];
    if(c==N) return dp[a][b][c]=0;
    double ret=1;
    if(a<N) ret+=((N-a)*Solve(a+1,b,c))/N;
    if(b<N) ret+=((a-b)*Solve(a,b+1,c))/N;
    if(c<N) ret+=((b-c)*Solve(a,b,c+1))/N;
    return dp[a][b][c]=(N*ret)/(N-c);
}
int main(){
    cin>>N;
    rep(i,N){
        ll x; cin>>x;
        if(x>=3) C++;
        if(x>=2) B++;
        if(x>=1) A++;
    }
    rep(i,101) rep(j,101) rep(k,101) dp[i][j][k]=-2;
    cout<<setprecision(9)<<Solve(A,B,C)<<endl;

}
0