Pagini recente » Monitorul de evaluare | Cod sursa (job #1460143) | Istoria paginii runda/valioiancur | Cod sursa (job #483764) | Cod sursa (job #273886)
Cod sursa(job #273886)
#include<stdio.h>
#define IN "dezastru.in","r",stdin
#define OUT "dezastru.out","w",stdout
int n,T,nr,sol[30];
double rez;
double prob[30];
int marc[30];
void citire()
{
freopen(IN);
scanf("%d%d",&n,&T);
for(int i=1;i<=n;++i)
scanf("%lf",&prob[i]);
}
inline void back(int k, double rez1)
{
if(k==T+1)
{
rez+=rez1;
++nr;
return;
}
for(int i=sol[k-1]+1;i<=n-T+k;++i)
{
sol[k]=i;
back(k+1, rez1*prob[i]);
}
}
void afisare()
{
freopen(OUT);
printf("%.6lf\n",rez/nr);
}
int main()
{
citire();
back(1, 1);
afisare();
return 0;
}