Pagini recente » Istoria paginii utilizator/emanuel.ursache | Profil Dj_AioN | Istoria paginii utilizator/manolescu_mircea_324ca | Istoria paginii utilizator/echipabossilor | Cod sursa (job #1451036)
/*
If you can't explain it simply, you don't understand it well enough.
*/
#include <cstdio>
#include <algorithm>
using namespace std;
const int Nmax = 30;
int n , k , i , j;
int comb[Nmax][Nmax];
double D[Nmax][Nmax] , p[Nmax];
int main()
{
freopen("dezastru.in","r",stdin);
freopen("dezastru.out","w",stdout);
scanf("%d %d", &n, &k);
for (i = 1; i <= n; ++i)
scanf("%lf", &p[i]);
for (i = 0; i <= n; ++i)
D[i][0] = 1,
comb[i][0] = 1;
for (i = 1; i <= n; ++i)
for (j = 1; j <= i; ++j)
D[i][j] = D[i-1][j] + D[i-1][j-1] * p[i],
comb[i][j] = comb[i-1][j] + comb[i-1][j-1];
printf("%.6lf", D[n][k] / comb[n][k]);
return 0;
}