Pagini recente » Cod sursa (job #1019489) | Cod sursa (job #13986) | Cod sursa (job #2369316) | Cod sursa (job #2959034) | Cod sursa (job #2776580)
#include <bits/stdc++.h>
using namespace std;
ifstream f("dezastru.in");
ofstream g("dezastru.out");
#define cin f
#define cout g
//#define int long long
const int Max = 26;
void nos()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int n,k;
double a[Max];
int prod;
void read()
{
prod = 1;
f>>n>>k;
int i;
for(i=1;i<=n;i++)
{
f>>a[i];
}
}
vector< double > prob;
vector < int > choose;
double choose_product = 1;
long double ans = 0;
int cnt = 0;
void generate_bkt(int current)
{
if(current == k + 1)
{
ans += choose_product;
cnt++;
return;
}
double auxchoose = choose_product;
int start = 1;
if(!choose.empty())
start = choose.back() + 1;
for(int i = start;i<=n;i++)
{
choose_product *= a[i];
choose.push_back(i);
generate_bkt(current + 1);
choose.pop_back();
choose_product = auxchoose;
}
}
void solve()
{
generate_bkt(1);
ans /= cnt;
cout<<fixed<<setprecision(10)<<ans<<'\n';
}
void restart()
{
}
int32_t main()
{
nos();
read();
solve();
restart();
return 0;
}