Pagini recente » Cod sursa (job #2332876) | Cod sursa (job #2279890) | Rating Raluca Petrovici (justthat99) | Istoria paginii runda/2525 | Cod sursa (job #2532002)
#include <fstream>
#include <string>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#include <map>
#include <string.h>
#include <queue>
#include <stack>
#define INF 0x3f3f3f3f
using namespace std;
#ifdef DEBUG
string name = "data";
#else
string name = "dezastru";
#endif
ifstream fin(name + ".in");
ofstream fout(name + ".out");
int n,k;
double p[50];
double best = 0;
int cnt = 0;
void back(int i, int s, double sum) {
if (s == k) {
best += sum;
cnt++;
return;
}
for (int j = i; j <=n; ++j) {
back(j + 1, s + 1, sum * p[j]);
}
}
int main() {
fin >> n >> k;
for (int i = 1; i <= n; ++i) {
fin >> p[i];
}
back(1, 0, 1);
fout << best / cnt;
return 0;
}