Cod sursa(job #1884972)

Utilizator andy1207Cioltan Andrei andy1207 Data 19 februarie 2017 15:26:20
Problema Dezastru Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.54 kb
#include<cstdio>

const int Nmax=25;

int a[Nmax+1][Nmax+1];
double v[Nmax+1];
double d[Nmax+1][Nmax+1];

int main()
{
 int n,k;
 freopen("dezastru.in","r",stdin);
 freopen("dezastru.out","w",stdout);
 scanf("%d %d ",&n,&k);
 for(int i=1;i<=n;i++)
    {
     scanf("%lf",&v[i]);
    }
 a[0][0]=d[0][0]=1;
 for(int i=1;i<=n;i++)
    {
     for(int j=0;j<=k;j++)
        {
         a[i][j]=a[i-1][j]+a[i-1][j-1];
         d[i][j]=d[i-1][j]+d[i-1][j-1]*v[i];
        }
    }
 printf("%.6lf",d[n][k]/a[n][k]);
return 0;
}