Cod sursa(job #496843)
| Utilizator | Data | 30 octombrie 2010 22:19:54 | |
|---|---|---|---|
| Problema | Dezastru | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.49 kb |
#include<stdio.h>
#include<math.h>
int n,j,k,sol;
double stot,rasp,s[30];
void back(int l,int pi,double qq)
{
if(l==k)
{
stot+=qq;
sol++;
return;
}
for(int i=pi+1;i<=n+l-k+1;i++)
back(l+1,i,qq*s[i]);
}
int main()
{
freopen("dezastru.in","r",stdin);
freopen("dezastru.out","w",stdout);
scanf("%d%d",&n,&k);
for(int i=1;i<=n;i++)
scanf("%lf",&s[i]);
back(0,0,1.0);
rasp=(double)stot/(double)sol;
printf("%.6lf",rasp*2);
return 0;
}
