Cod sursa(job #755268)
| Utilizator | Data | 5 iunie 2012 09:21:28 | |
|---|---|---|---|
| Problema | Dezastru | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.49 kb |
#include <cstdio>
using namespace std;
float s,q,w,a[100];
long n,k,i;
double suma(int c,double prod,int r)
{
double t=0;
long j;
if(r==0){t=prod;}
else{for(j=c;j<=n-r+1;j++){t+=suma(j+1,prod*a[j],r-1);}}
return t;
}
int main()
{
freopen("dezastru.in","r",stdin);
freopen("dezastru.out","w",stdout);
scanf("%d%d\n",&n,&k);
for(i=1;i<=n;i++){
scanf("%f",&a[i]);
}
s=suma(1,1,k);q=1;
for(i=k+1;i<=n;i++){q*=i;}
w=1/q;w*=s;printf("%f",w);
return 0;
}
