Cod sursa(job #1402174)

Utilizator valentin50517Vozian Valentin valentin50517 Data 26 martie 2015 13:14:10
Problema Dezastru Scor 60
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.55 kb
#include <fstream>
#include <iomanip>

using namespace std;

ifstream fin("dezastru.in");
ofstream fout("dezastru.out");
int n,k,comb;
double A[27],rs;

void back(int poz,int p,double pas){
     if(p == k){
          rs+= pas;
          comb++;
     }else     
     for(int i = poz;i<n;i++){         
                    back(i+1,p+1,pas*A[i]);
     }    
}

int main(){
    fin >> n >> k;
    for(int i = 0;i<n;i++) fin >> A[i];
    back(0,0,1);
    
    fout << setprecision(7) << fixed <<rs / comb;
    
    
    return 0;    
}