Pagini recente » Cod sursa (job #1711900) | Cod sursa (job #171760) | Cod sursa (job #2384295) | Cod sursa (job #2760449) | Cod sursa (job #164923)
Cod sursa(job #164923)
{$N+}
const nmax=26;
var f:text;
comb:array[0..nmax,0..nmax] of longint;
i,n,k,j:byte;
v:array[1..nmax] of real;
mat: array[0..nmax,0..nmax] of extended;
Begin
assign(f,'dezastru.in');reset(f);
readln(f,n,k);
for i:=1 to n do
read(f,v[i]);
close(f);
comb[1,0]:=1; comb[1,1]:=1;
mat[1,1]:=v[1]; mat[1,0]:=1;
for i:=2 to n do
begin
comb[i,0]:=1;
mat[i,0]:=1;
j:=1;
while (j<=i) and (j<=k) do begin
mat[i,j]:=mat[i-1,j]+mat[i-1,j-1]*v[i];
comb[i,j]:=comb[i-1,j]+comb[i-1,j-1];
j:=j+1;
end;
end;
assign(f,'dezastru.out');rewrite(f);
write(f,mat[n,k]/comb[n,k]:0:6);
close(f);
End.