結果

問題 No.108 トリプルカードコンプ
ユーザー bonntanname0316bonntanname0316
提出日時 2020-06-02 18:44:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,163 bytes
コンパイル時間 1,558 ms
コンパイル使用メモリ 168,676 KB
実行使用メモリ 14,016 KB
最終ジャッジ日時 2024-05-03 08:33:07
合計ジャッジ時間 8,259 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
11,672 KB
testcase_01 AC 4 ms
11,796 KB
testcase_02 AC 4 ms
11,680 KB
testcase_03 AC 4 ms
11,604 KB
testcase_04 AC 4 ms
11,664 KB
testcase_05 AC 3 ms
11,672 KB
testcase_06 AC 3 ms
11,684 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

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]=-5;
    cout<<setprecision(9)<<Solve(A,B,C)<<endl;

}
0