Pagini recente » Cod sursa (job #196450) | Cod sursa (job #1581462) | Cod sursa (job #22554) | Cod sursa (job #2186373) | Cod sursa (job #2635091)
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
const ll mod=1e9+7;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int maxn=1e7+5;
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define rc(x) return cout<<x<<"\n",0
#define sz(s) (int) s.size()
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
using namespace std;
double rasp=0;
ll t,s[28],cnt,n,k;
double prob[maxn];
vector<double>ans;
void perm(int p, int ind, double s) {
if (ind <= n && p == k) {
cnt++;
rasp+=s;
return;
}
else {
for (int i=ind+1; i<=n; i++) {
perm(p+1,i,s*prob[i]);
}
}
}
int main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ifstream cin("dezastru.in");
ofstream cout("dezastru.out");
cin >> n >> k;
for (int i=1; i<=n; i++) {
cin >> prob[i];
}
perm(0,0,1);
rasp/=cnt;
cout << rasp << '\n';
}