Cod sursa(job #1198115)
| Utilizator | Data | 14 iunie 2014 16:55:17 | |
|---|---|---|---|
| Problema | Dezastru | Scor | 30 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.46 kb |
#include <fstream>
#include <iomanip>
using namespace std;
double a[30],ans=0;
int k,n,nr=0;
bool seen[30];
void comb(double s,int x){
if(x==k+1){
ans+=s;
nr++;
return;
}
for(int i=1;i<=n;i++){
if(!seen[i]){
seen[i]=1;
comb(s*a[i],x+1);
}
seen[i]=0;
}
};
int main(){
ifstream f("dezastru.in");
ofstream g("dezastru.out");
f >> n >> k;
for(int i=1;i<=n;i++){
f >> a[i];
}
comb(1,1);
ans/=nr;
g << fixed << setprecision(6) << ans;
}
