思路:
#include <cstdio> #include <algorithm> using namespace std; const int N = 15; double a[N],b[N],c[N],p[N]; double f[N][N]; int main(){ for(int i = 1;i <= 12;i++){ scanf("%lf",a+i); } for(int i = 1;i <= 12;i++){ scanf("%lf",b+i); } for(int i = 1;i <= 12;i++){ scanf("%lf",c+i); } for(int i = 1;i <= 12;i++){ p[i] = a[i] + b[i] + c[i] - a[i]*b[i] - c[i]*b[i] - a[i]*c[i] + a[i] * b[i] * c[i]; } f[0][0] = 1.0; for(int i = 1;i <= 12;i++){ f[i][0] = f[i-1][0] * (1 - p[i]); for(int j = 1;j <= 12;j++){ f[i][j] = p[i] * f[i-1][j-1] + (1 - p[i]) * f[i-1][j]; } } for(int i = 0;i <= 12;i++){ printf("%.6f\n",f[12][i]); } return 0; }