Cod sursa(job #1198153)

Utilizator tudi98Cozma Tudor tudi98 Data 14 iunie 2014 18:40:32
Problema Dezastru Scor 70
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.41 kb
#include <fstream>
#include <iomanip>

using namespace std;

int nr=0,k,n;
double p[30],ans;

void comb(int x,double s,int last){
	int i;
	if(x==k+1){
		ans+=s;
		nr++;
		return;
	}
	for(i=last+1;i<=n;i++){
		comb(x+1,p[i]*s,i);
	}
}


int main(){
	
	ifstream f("dezastru.in");
	ofstream g("dezastru.out");

	f >> n >> k;
	for(int i=1;i<=n;i++) 
		f >> p[i];

	comb(1,1,0);
	
	g << fixed << setprecision(6) << ans/nr;

}