Pagini recente » Cod sursa (job #2278615) | Istoria paginii runda/eusebiu_oji_2011_cls11-12 | Cod sursa (job #2438913) | Cod sursa (job #312355) | Cod sursa (job #2025606)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("dezastru.in");
ofstream fout("dezastru.out");
long long cst;
double dz, s, v[30], sum;
int tot, n, k, i, j, d[30];
long long factorial (int x)
{
if (x == 1) return 1;
else return x * factorial(x-1);
}
int calc () {
double po = 1;
for (int i = 1; i <= k; i++)
po *= v[d[i]];
tot++; sum += po;
return po;
}
void back (int p) {
for (int i = d[p-1]+1; i <= n; i++)
{
d[p] = i;
if (p == k) calc();
else back (p+1);
}
}
int main () {
fin >> n >> k;
for (i = 1; i <= n; i++)
fin >> v[i];
back(1);
fout << sum/tot << "\n";
return 0;
}