Pagini recente » Cod sursa (job #266053) | Cod sursa (job #572828) | Cod sursa (job #1535071) | Cod sursa (job #1601319) | Cod sursa (job #3290442)
#include <bits/stdc++.h>
using namespace std;
int n, k;
int cnt = 0;
long double ans = 0;
vector<int> vis;
vector<long double> v;
void calc(int i = 0, int pj = -1, long double x = 1)
{
if(i == k)
{
ans += (x);
cnt++;
return;
}
for(int j = pj + 1; j < n; j++)
{
if(!vis[j])
{
calc(i+1, j, x * v[j]);
}
}
}
int main()
{
freopen("dezastru.in", "r", stdin);
freopen("dezastru.out", "w", stdout);
cin.tie(nullptr)->sync_with_stdio(false);
cin >> n >> k;
vis.resize(n);
for(int i = 0; i < n; i++)
{
long double x;
cin >> x;
v.push_back(x);
}
calc();
cout << fixed << setprecision(6) << ans / cnt;
}