Pagini recente » Cod sursa (job #2977087) | Cod sursa (job #2777577) | Cod sursa (job #1339335) | Cod sursa (job #540622) | Cod sursa (job #251673)
Cod sursa(job #251673)
#include <stdio.h>
int n,m,pe;
double a[30];
double sum;
void back (int k,int val,double s)
{
int i;
if (k==m+1)
{
sum+=s;
++pe;
}
else
for (i=val; i<=n-m+k; ++i)
back (k+1,i+1,s*a[i]);
}
int main ()
{
freopen ("dezastru.in","r",stdin);
int i;
scanf ("%d%d",&n,&m);
for (i=1; i<=n; ++i)
scanf ("%lf",&a[i]);
fclose(stdin);
back (1,1,1);
freopen ("dezastru.out","w",stdout);
printf ("%.6lf",sum/pe);
fclose(stdout);
return 0;
}