Cod sursa(job #3294414)
| Utilizator | Data | 22 aprilie 2025 19:37:57 | |
|---|---|---|---|
| Problema | Dezastru | Scor | 20 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.53 kb |
#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;
}
