結果
問題 |
No.108 トリプルカードコンプ
|
ユーザー |
|
提出日時 | 2025-07-03 16:54:38 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 21 ms / 5,000 ms |
コード長 | 950 bytes |
コンパイル時間 | 1,854 ms |
コンパイル使用メモリ | 204,952 KB |
実行使用メモリ | 20,096 KB |
最終ジャッジ日時 | 2025-07-03 16:54:42 |
合計ジャッジ時間 | 3,087 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; int zero = 0,one = 0,two = 0; for(int i=0; i<N; i++){ int a; cin >> a; if(a == 0) zero++; if(a == 1) one++; if(a == 2) two++; } long double answer = 0; vector dp(N+1,vector(N+1,vector<long double>(N+1))); dp.at(zero).at(one).at(two) = 1; for(int i=N; i>=0; i--) for(int k=N; k>=0; k--) for(int l=N; l>=0; l--){ if(i+k+l == 0) continue; long double d = dp.at(i).at(k).at(l); if(d == 0) continue; int left = N-i-k-l; long double mul = N/(N-left+0.0),div = 1.0/(i+k+l); answer += d*mul; if(i) dp.at(i-1).at(k+1).at(l) += i*div*d; if(k) dp.at(i).at(k-1).at(l+1) += k*div*d; if(l) dp.at(i).at(k).at(l-1) += l*div*d; } cout << fixed << setprecision(20) << answer << endl; }