Cod sursa(job #631117)

Utilizator sunt_emoSunt emo sunt_emo Data 7 noiembrie 2011 00:35:52
Problema Dezastru Scor 70
Compilator c Status done
Runda Arhiva de probleme Marime 0.48 kb
#include <stdio.h>

short n,a[30],k,i;
double p,b[30];
int c;

void comb (int x,int m,double p1) {
    int i;
    if (x==k) {
        p+=p1;
        c++;
        return;
    }
    for (i=m; i<=n-k+x+1; i++) comb (x+1,i+1,p1*b[i-1]);
}

int main () {
    freopen ("dezastru.in","r",stdin);
    freopen ("dezastru.out","w",stdout);
    scanf ("%hd%hd",&n,&k);
    for (i=0; i<n; i++) scanf ("%lf",b+i);
    comb (0,1,1);
    printf ("%.6lf\n",p/c);
    return 0;
}