Mai intai trebuie sa te autentifici.
Cod sursa(job #596579)
Utilizator | Data | 17 iunie 2011 19:32:01 | |
---|---|---|---|
Problema | Dezastru | Scor | 90 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.52 kb |
#include<cstdio>
#include<fstream>
using namespace std;
short n,k,v[27],uz[27];
double a[27],suma;
int numar;
void Back(short pas,short x,double p)
{
if(pas==k)
{
suma+=p;
numar++;
}
else
{
short i;
for(i=x+1;i<=n-k+pas+1;i++)
{
Back(pas+1,i,p*a[i]);
}
}
}
int main()
{
int i;
ifstream fin("dezastru.in");
fin>>n>>k;
for(i=1;i<=n;i++)
fin>>a[i];
fin.close();
Back(0,0,1);
suma=suma/numar;
freopen("dezastru.out","w",stdout);
printf("%.6f\n",suma);
return 0;
}