Cod sursa(job #173733)

Utilizator andrei-alphaAndrei-Bogdan Antonescu andrei-alpha Data 7 aprilie 2008 23:53:01
Problema Dezastru Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.48 kb
#include <stdio.h>
#define N 30
int n,k;
int a[N][N];
float v[N],b[N][N];
void scan()
{
	freopen("dezastru.in","r",stdin);
	freopen("dezastru.out","w",stdout);
	scanf("%d%d",&n,&k); ++k;
	for(int i=1;i<=n;++i)
		scanf("%f", &v[i]);
}	
void solve()
{
	a[0][1]=1; b[0][1]=1;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=k;++j)
		{
			a[i][j]=a[i-1][j]+a[i-1][j-1];
			b[i][j]=b[i-1][j]+b[i-1][j-1]*v[i];
		}
	printf("%f", b[n][k]/a[n][k]);
}
int main()
{
	scan();
	solve();
	return 0;
}