結果

問題 No.108 トリプルカードコンプ
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2014-12-22 00:24:37
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,212 bytes
コンパイル時間 808 ms
コンパイル使用メモリ 85,436 KB
実行使用メモリ 15,532 KB
最終ジャッジ日時 2023-09-02 21:09:26
合計ジャッジ時間 2,003 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
9,556 KB
testcase_01 AC 4 ms
9,616 KB
testcase_02 AC 4 ms
9,544 KB
testcase_03 AC 4 ms
9,560 KB
testcase_04 AC 4 ms
9,468 KB
testcase_05 AC 4 ms
9,432 KB
testcase_06 AC 4 ms
9,396 KB
testcase_07 AC 13 ms
15,384 KB
testcase_08 AC 6 ms
15,532 KB
testcase_09 AC 5 ms
13,568 KB
testcase_10 AC 4 ms
9,452 KB
testcase_11 AC 4 ms
9,604 KB
testcase_12 WA -
testcase_13 AC 5 ms
12,304 KB
testcase_14 AC 5 ms
12,300 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 4 ms
9,580 KB
testcase_18 AC 10 ms
15,324 KB
testcase_19 AC 7 ms
15,280 KB
testcase_20 AC 6 ms
14,128 KB
testcase_21 AC 8 ms
14,924 KB
testcase_22 AC 5 ms
11,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(long long i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
 
#define MOD 1000000007

int N;
int memo[101][101][101];
double dp[101][101][101];

double f(int a, int b, int c){
  if(a==0&&b==0&&c==0)return 0.;
  if(memo[a][b][c]!=-1)return dp[a][b][c];
  double ret = 0.;
  if(a-1>=0)ret += 1.*a/(a+b+c)*f(a-1,b,c);
  if(b-1>=0)ret += 1.*b/(a+b+c)*f(a+1,b-1,c);
  if(c-1>=0)ret += 1.*c/(a+b+c)*f(a,b+1,c-1);
  ret+=1.*N/(a+b+c);
  memo[a][b][c] = 1;
  return dp[a][b][c] = ret;
}

int main(){
  clr(memo,-1);
  cin>>N;
  int a=0,b=0,c=0;
  rep(i,0,N){
    int d;
    cin>>d;
    if(d==2)a++;
    if(d==1)b++;
    if(d==0)c++;
  }
  cout << f(a,b,c) << endl;
  return 0;
}
0