結果

問題 No.108 トリプルカードコンプ
ユーザー bonntanname0316bonntanname0316
提出日時 2020-06-02 19:02:41
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 5,000 ms
コード長 1,345 bytes
コンパイル時間 1,510 ms
コンパイル使用メモリ 168,032 KB
実行使用メモリ 12,608 KB
最終ジャッジ日時 2023-08-15 22:32:21
合計ジャッジ時間 2,668 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
11,588 KB
testcase_01 AC 5 ms
11,524 KB
testcase_02 AC 5 ms
11,528 KB
testcase_03 AC 5 ms
11,616 KB
testcase_04 AC 5 ms
11,748 KB
testcase_05 AC 5 ms
11,800 KB
testcase_06 AC 4 ms
11,788 KB
testcase_07 AC 11 ms
12,608 KB
testcase_08 AC 5 ms
11,604 KB
testcase_09 AC 5 ms
11,588 KB
testcase_10 AC 4 ms
11,600 KB
testcase_11 AC 5 ms
11,732 KB
testcase_12 AC 5 ms
11,768 KB
testcase_13 AC 5 ms
11,728 KB
testcase_14 AC 5 ms
11,648 KB
testcase_15 AC 5 ms
11,764 KB
testcase_16 AC 5 ms
11,828 KB
testcase_17 AC 5 ms
11,768 KB
testcase_18 AC 9 ms
12,388 KB
testcase_19 AC 7 ms
11,864 KB
testcase_20 AC 6 ms
11,620 KB
testcase_21 AC 8 ms
12,060 KB
testcase_22 AC 5 ms
11,800 KB
権限があれば一括ダウンロードができます

ソースコード

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];
bool arrived[101][101][101];
ll N;
ll A,B,C;

ll Count=0;
double Solve(ll a, ll b, ll c){
    if(arrived[a][b][c]) return dp[a][b][c];
    arrived[a][b][c]=true;

    if(c>=N) return dp[a][b][c]=0;
    //Count++;
    //if(Count>1e7) return -1;
    //cout<<Count<<':'<<a<<' '<<b<<' '<<c<<endl;
    double ret=1;
    if(a<N) ret+=((N-a)*Solve(a+1,b,c))/N;
    if(a>b && b<N) ret+=((a-b)*Solve(a,b+1,c))/N;
    if(b>c && 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