Pagini recente » Cod sursa (job #2835779) | Cod sursa (job #3191799) | Diferente pentru problema/ab intre reviziile 19 si 11 | Cod sursa (job #39742)
Cod sursa(job #39742)
const maxn = 25;
var f:text;
n,k,i,j:longint;
sol,r:real;
a:array[1..maxn]of real;
c:array[1..maxn,1..maxn]of real;
procedure readdata;
begin
assign(f,'dezastru.in');
reset(f);
readln(f,n,k);
for i:=1 to n do
begin
read(f,a[i]);
end;
close(f);
end;
procedure solve;
begin
c[1,1]:=a[1];
for i:=2 to n do c[i,1]:=c[i-1,1]+a[i];
for i:=2 to n do
begin
for j:=2 to k do
begin
c[i,j]:=c[i-1,j]+c[i-1,j-1]*a[i]
end;
end;
end;
procedure writedata;
begin
assign(f,'dezastru.out');
rewrite(f);
sol:=c[n,k];
r:=1;
for i:=k+1 to n do
begin
r:=r*i/(i-k);
end;
writeln(f,sol/r:0:6);
close(f);
end;
begin
readdata;
solve;
writedata;
end.