結果
問題 | No.108 トリプルカードコンプ |
ユーザー | pione |
提出日時 | 2020-12-11 00:21:04 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 11 ms / 5,000 ms |
コード長 | 2,232 bytes |
コンパイル時間 | 1,426 ms |
コンパイル使用メモリ | 166,108 KB |
実行使用メモリ | 8,192 KB |
最終ジャッジ日時 | 2024-09-19 20:57:16 |
合計ジャッジ時間 | 2,371 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 1 ms
6,944 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | AC | 11 ms
8,192 KB |
testcase_08 | AC | 6 ms
8,192 KB |
testcase_09 | AC | 2 ms
6,940 KB |
testcase_10 | AC | 2 ms
6,944 KB |
testcase_11 | AC | 1 ms
6,944 KB |
testcase_12 | AC | 2 ms
6,944 KB |
testcase_13 | AC | 3 ms
6,940 KB |
testcase_14 | AC | 3 ms
6,944 KB |
testcase_15 | AC | 2 ms
6,944 KB |
testcase_16 | AC | 3 ms
6,940 KB |
testcase_17 | AC | 2 ms
6,944 KB |
testcase_18 | AC | 9 ms
7,552 KB |
testcase_19 | AC | 6 ms
7,296 KB |
testcase_20 | AC | 4 ms
6,940 KB |
testcase_21 | AC | 8 ms
7,168 KB |
testcase_22 | AC | 2 ms
6,944 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; // #define int long long #define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i) #define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i) #define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--) #define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--) #define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i) #define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i) #define irreps(i, m, n) for (long long i = ((long long)(n)-1); i > (long long)(m); ++i) #define SORT(v, n) sort(v, v + n); #define REVERSE(v, n) reverse(v, v+n); #define vsort(v) sort(v.begin(), v.end()); #define all(v) v.begin(), v.end() #define mp(n, m) make_pair(n, m); #define cinline(n) getline(cin,n); #define replace_all(s, b, a) replace(s.begin(),s.end(), b, a); #define PI (acos(-1)) #define FILL(v, n, x) fill(v, v + n, x); #define sz(x) (long long)(x.size()) using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vll = vector<ll>; using vvll = vector<vll>; using pii = pair<int, int>; using pll = pair<ll, ll>; using vs = vector<string>; using vpll = vector<pair<ll, ll>>; using vtp = vector<tuple<ll,ll,ll>>; using vb = vector<bool>; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template<class t> using vc=vector<t>; template<class t> using vvc=vc<vc<t>>; const ll INF = 1e9+10; const ll MOD = 1e9+7; const ll LINF = 1e18; double dp[105][105][105]; ll n; double rec(ll x, ll y, ll z){ if(z>=n) return 0; if(dp[x][y][z]) return dp[x][y][z]; double res=1; ll zero=n-(x+y+z); if(zero>0) res+=rec(x+1,y,z)*((double)zero/n); if(x) res+=rec(x-1,y+1,z)*((double)x/n); if(y) res+=rec(x,y-1,z+1)*((double)y/n); res=res*n*1.0/(n-z); return dp[x][y][z]=res; } signed main() { cin.tie( 0 ); ios::sync_with_stdio( false ); cin>>n; ll x,y,z; x=y=z=0; rep(i,n) { ll a; cin>>a; if(a==1) x++; if(a==2) y++; if(a>=3) z++; } double ans=rec(x,y,z); printf("%.15lf\n", ans); }