Cod sursa(job #2590870)
| Utilizator | Data | 29 martie 2020 10:17:01 | |
|---|---|---|---|
| Problema | Dezastru | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.55 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("dezastru.in");
ofstream g("dezastru.out");
int x[26], n, p, nrperm, i;
double v[26], s;
void back(int k, double prod)
{
for(int i = 1; i <= n; ++ i)
{
x[k] = i;
if(k == p)
{
s = s + prod * v[x[k]];
nrperm ++;
}
else back(k + 1, prod * v[x[k]]);
}
}
int main()
{
cin >> n >> p;
for(i = 1; i <= n; ++ i)
cin >> v[i];
back(1, 1);
cout << (double)s/nrperm;
return 0;
}
