Cod sursa(job #1481305)
| Utilizator | Data | 4 septembrie 2015 10:13:48 | |
|---|---|---|---|
| Problema | Dezastru | Scor | 100 |
| Compilator | c | Status | done |
| Runda | Arhiva de probleme | Marime | 0.46 kb |
#include<stdio.h>
int n,k,i,j;
double p[26],a[26][26],c[26][26];
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]),a[i][0]=1,c[i][1]=i;
for(a[0][0]=i=1;i<=k;i++)
for(j=i;j<=n;j++)
a[j][i]=a[j-1][i]+a[j-1][i-1]*p[j];
for(i=2;i<=n;i++)
for(j=2;j<=i;j++)
c[i][j]=c[i-1][j-1]+c[i-1][j];
printf("%.6lf",a[n][k]/c[n][k]);
}
