Cod sursa(job #491642)
| Utilizator | Data | 11 octombrie 2010 21:37:53 | |
|---|---|---|---|
| Problema | Dezastru | Scor | 70 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.54 kb |
#include <stdio.h>
int n,k,a[26],c;
double p[26],pos=1,s;
inline void back(int x)
{
if (x==k+1)
{
s+=pos;
++c;
return;
}
int i,b=a[x-1]+1;
for (i=b;i<=n-k+x;++i)
{
pos*=p[i];a[x]=i;
back(x+1);
pos/=p[i];
}
}
int main()
{
int i;
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]);
back(1);
s/=c;
printf("%.6lf",s);
return 0;
}
