Pagini recente » Cod sursa (job #222043) | Cod sursa (job #1862893) | Diferente pentru teorema-chineza-a-resturilor intre reviziile 69 si 89 | Cod sursa (job #3191543) | Cod sursa (job #3294414)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("dezastru.in");
ofstream fout("dezastru.out");
int n, k, a[26], cnt = 0;
double p[26], s = 0;
int main()
{
fin >> n >> k;
for(int i = 1; i <= n; i++)
fin >> p[i];
iota(a + 1, a + n + 1, 1);
do
{
cnt++;
double crt = 1;
for(int i = 1; i <= k; i++)
crt *= p[a[i]];
s += crt;
}while(next_permutation(a + 1, a + n + 1));
fout << fixed << setprecision(6) << s / cnt;
return 0;
}