結果
問題 |
No.108 トリプルカードコンプ
|
ユーザー |
|
提出日時 | 2020-06-02 19:02:41 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 9 ms / 5,000 ms |
コード長 | 1,345 bytes |
コンパイル時間 | 1,571 ms |
コンパイル使用メモリ | 168,868 KB |
実行使用メモリ | 12,492 KB |
最終ジャッジ日時 | 2024-11-24 07:40:13 |
合計ジャッジ時間 | 2,398 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#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; }