#include #include using namespace std; class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x 0) { E[k0][k1][k2] += E[k0-1][k1+1][k2] * k0 / k; } if(k1 > 0) { E[k0][k1][k2] += E[k0] [k1-1][k2+1] * k1 / k; } if(k2 > 0) { E[k0][k1][k2] += E[k0] [k1] [k2-1] * k2 / k; } } } } vector x(3); for(int i : range(n)) { int a; scanf("%d", &a); if(a < 3) { x[a]++; } } printf("%f\n", E[x[0]][x[1]][x[2]]); return 0; }