Mai intai trebuie sa te autentifici.
Cod sursa(job #1282999)
Utilizator | Data | 4 decembrie 2014 22:44:12 | |
---|---|---|---|
Problema | Dezastru | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.56 kb |
#include <cstdio>
using namespace std;
int st[30],n,k,p;
float s,b[30];
void abc()
{
float w=1;
for(int i=1;i<=k;i++)w*=b[st[i]];
s+=(2.0*w)/float(p);
}
void back(int x)
{
if(x>k)abc();
else for(int i=x;i<=n;i++)
{
st[x]=i;
if(st[x]>st[x-1])
back(x+1);
}
}
int main()
{
freopen("dezastru.in","r",stdin);
freopen("dezastru.out","w",stdout);
scanf("%d%d",&n,&k);
p=1;
for(int i=n-k+1;i<=n;i++)p=p*1LL*i;
for(int i=1;i<=n;i++)scanf("%f",&b[i]);
back(1);
printf("%.6f",s);
return 0;
}