Pagini recente » Cod sursa (job #2538813) | Cod sursa (job #2878435) | Cod sursa (job #458769) | Cod sursa (job #1323494) | Cod sursa (job #762030)
Cod sursa(job #762030)
#include<cstdio>
using namespace std;
int d1(int a)
{
if(!a)
return 0;
return 1+d1(a&(a-1));
}
float v[500],v1[90000000],s=0;
int main()
{
freopen("dezastru.in","r",stdin);freopen("dezastru.out","w",stdout);
int i,j,n,k,bit,index=0;
scanf("%d%d",&n,&k);
bit=(1<<n)-1;
for(i=1;i<=n;i++)
scanf("%f",&v[i]);
for(i=1;i<=bit;i++)
{
if(d1(i)!=k)
continue;
v1[++index]=1;
for(j=0;j<n;j++)
if((i>>j)&1)
v1[index]*=v[j+1];
}
for(i=1;i<=index;i++)
s+=v1[i]/index;
printf("%f",s);
}