結果
| 問題 | No.108 トリプルカードコンプ |
| コンテスト | |
| ユーザー |
shinchan
|
| 提出日時 | 2020-03-17 23:39:07 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 101 ms / 5,000 ms |
| コード長 | 785 bytes |
| コンパイル時間 | 1,511 ms |
| コンパイル使用メモリ | 167,920 KB |
| 実行使用メモリ | 216,960 KB |
| 最終ジャッジ日時 | 2024-11-30 23:28:32 |
| 合計ジャッジ時間 | 4,817 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
double dp[301][301][301];
int n;
double solve(int i,int j,int k){
if(dp[i][j][k]>=0)return dp[i][j][k];
if(!(i|j|k))return 0.0;
double res=0.0;
if(i)res+=solve(i-1,j,k)*i;
if(j)res+=solve(i+1,j-1,k)*j;
if(k)res+=solve(i,j+1,k-1)*k;
res+=n;
res/=(i+j+k);
return dp[i][j][k]=res;
}
int main() {
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(false);
cin>>n;
int a,c[4]={0};
for(int i=0;i<n;i++){
cin>>a;
//c[a]++;
if(a<3)c[3-a]++;
}
memset(dp,-1,sizeof(dp));
doublecout(solve(c[1],c[2],c[3]));
return 0;
}
shinchan