結果

問題 No.108 トリプルカードコンプ
ユーザー aogeraaogera
提出日時 2024-04-05 22:53:08
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 25 ms / 5,000 ms
コード長 2,213 bytes
コンパイル時間 9,114 ms
コンパイル使用メモリ 351,424 KB
実行使用メモリ 24,320 KB
最終ジャッジ日時 2024-04-05 22:53:18
合計ジャッジ時間 9,822 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
24,320 KB
testcase_01 AC 18 ms
24,320 KB
testcase_02 AC 18 ms
24,320 KB
testcase_03 AC 18 ms
24,320 KB
testcase_04 AC 19 ms
24,320 KB
testcase_05 AC 18 ms
24,320 KB
testcase_06 AC 18 ms
24,320 KB
testcase_07 AC 25 ms
24,320 KB
testcase_08 AC 19 ms
24,320 KB
testcase_09 AC 18 ms
24,320 KB
testcase_10 AC 19 ms
24,320 KB
testcase_11 AC 19 ms
24,320 KB
testcase_12 AC 19 ms
24,320 KB
testcase_13 AC 19 ms
24,320 KB
testcase_14 AC 19 ms
24,320 KB
testcase_15 AC 19 ms
24,320 KB
testcase_16 AC 19 ms
24,320 KB
testcase_17 AC 18 ms
24,320 KB
testcase_18 AC 24 ms
24,320 KB
testcase_19 AC 20 ms
24,320 KB
testcase_20 AC 20 ms
24,320 KB
testcase_21 AC 21 ms
24,320 KB
testcase_22 AC 19 ms
24,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include <atcoder/all>
using namespace std;using namespace atcoder;using vst = vector<string>;using ll = long long;
using ld = long double;using pll = pair<ll,ll>;using vll = vector<ll>;using vvll = vector<vll>;using vpl = vector<pll>;
#define V(a) vector<a>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repp(i,k,n) for (ll i = k; i < n; i++)
#define per(i,s,e) for(ll i = s; i >= e; i--)
#define all(v) v.begin(),v.end()
#define yesno(a) a ? cout << "Yes" << '\n' : cout << "No" << '\n'
#define YESNO(a) a ? cout << "YES" << '\n' : cout << "NO" << '\n'
#define UNOmap unordered_map
#define UNOset unordered_set
#define join(G,a,b) G[a].push_back(b);G[b].push_back(a);
#define PB(a,b) a.emplace_back(b)
template<class... T>void in(T&... a){(cin >> ... >> a);}
template<class T, class... Ts>void out(const T& a, const Ts&... b){cout << a;((cout << ' ' <<  b), ...);cout << '\n';}
template<class T> void vin(vector<T> &v){for(ll i = 0; i < (ll)v.size(); i++)in(v[i]);}
template<class T> void vout(vector<T> &v){for(ll i = 0; i < (ll)v.size(); i++) cout << v[i] << ' ';cout << "\n";}
ll INF = 4611686018427387904;ll MOD9 =998244353; ll MOD1 =1000000007;
/* INF = 2^62 */
// #include<boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
using mint9 = modint998244353;
using mint1 = modint1000000007;
using mint = modint;
//----------------------------------------------


ll N;
vector dp(109,vector(109,vector(109,ld(-1))));

ld dfs(ll x,ll y, ll z){
  if(dp[x][y][z] != -1) return dp[x][y][z];
  dp[x][y][z] = 0;
  ld e = 1.0 * N /(N-z);
  
  if(x != N) dp[x][y][z] += (dfs(x+1,y,z) + e)*(N-x)/(N-z);
  if(y != x) dp[x][y][z] += (dfs(x,y+1,z) + e)*(x-y)/(N-z);
  if(z != y) dp[x][y][z] += (dfs(x,y,z+1) + e)*(y-z)/(N-z);
  return dp[x][y][z];
}




int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(15);
//==============================================
  
  in(N);
  dp[N][N][N] = 0;
  vll cnt(4);
  rep(i,N){
    ll a;
    in(a);
    rep(j,min(3LL,a)+1){
      cnt[j]++;
    }
  }
  
  out(dfs(cnt[1],cnt[2],cnt[3]));
}
0