結果
| 問題 | No.108 トリプルカードコンプ |
| コンテスト | |
| ユーザー |
pitsu_kyo_pro
|
| 提出日時 | 2019-12-21 17:05:56 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 10 ms / 5,000 ms |
| コード長 | 1,467 bytes |
| コンパイル時間 | 1,763 ms |
| コンパイル使用メモリ | 169,404 KB |
| 実行使用メモリ | 13,056 KB |
| 最終ジャッジ日時 | 2024-07-19 19:11:10 |
| 合計ジャッジ時間 | 2,582 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1LL << 60;
constexpr int INF = 1000000007;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
int N;
double dp[110][110][110];
vector<int> cnt(4,0);
double rec(int x, int y, int z){
if(dp[x][y][z] != -1) return dp[x][y][z];
dp[x][y][z] = 0;
double exp = 1.0*N/(N-z);
if(x != N) dp[x][y][z] += (rec(x+1,y,z) + exp)*(N-x)/(N-z);
if(y != x) dp[x][y][z] += (rec(x,y+1,z) + exp)*(x-y)/(N-z);
if(z != y) dp[x][y][z] += (rec(x,y,z+1) + exp)*(y-z)/(N-z);
return dp[x][y][z];
}
int main(){
cin >> N;
for(int i=0; i<=N; i++){
for(int j=0; j<=N; j++){
for(int k=0; k<=N; k++){
dp[i][j][k] = -1;
}
}
}
dp[N][N][N] = 0;
for(int i=0; i<N; i++){
int a;
cin >> a;
cnt[min(a,3)]++;
}
cnt[2] += cnt[3];
cnt[1] += cnt[2];
cout << fixed << setprecision(10) << rec(cnt[1],cnt[2],cnt[3]) << endl;
return 0;
}
pitsu_kyo_pro