Cod sursa(job #2211588)

Utilizator _Victor_Victor Ciobanu _Victor_ Data 10 iunie 2018 23:50:50
Problema Dezastru Scor 70
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.51 kb
#include <bits/stdc++.h>

using namespace std;

ifstream fin("dezastru.in");

long long np=0;
int n,km,S[26];
double P[26],V[26],s=0;

void bk(int k){
	if(k<=km){
		for(int i=S[k-1]+1;i<=n;i++){
			S[k]=i;
			V[k]=V[k-1]*P[i];
			bk(k+1);
			S[k]=0;
		}
	}else{
		np++;
		s+=V[k-1];
	}
}

int main(){
	freopen ("dezastru.out","w",stdout);
	V[0]=1;
	fin>>n>>km;
	for(int i=1;i<=n;i++) fin>>P[i];
	bk(1);
	s/=np;
	printf("%.6f",s);
	//cerr<<clock()*1000.0/CLOCKS_PER_SEC<<'\n';
	return 0;
}