Pagini recente » Cod sursa (job #1919067) | Cod sursa (job #1378579) | Cod sursa (job #1734609) | Cod sursa (job #1611787) | Cod sursa (job #574470)
Cod sursa(job #574470)
var a:array[1..25] of real;
x:array[0..25] of byte;
s,t:real;
n,k,h:byte;
i,j,z:longint;
procedure back(p:byte);
var i:byte;
begin
for i:=x[p-1]+1 to n-k+p do
begin
x[p]:=i;
s:=s*a[x[p]];
if p=k then t:=t+s
else back(p+1);
s:=s/a[x[p]];
end;
end;
begin
assign(input,'dezastru.in');
reset(input);
assign(output,'dezastru.out');
rewrite(output);
readln(n,k);
for i:=1 to n do read(a[i]);
s:=1;t:=0;
back(1);
h:=n-k;
i:=2;j:=2;z:=2;
while z<=n do
begin
if i<=k then
begin
t:=t*i;
inc(i);
end;
if j<=h then
begin
t:=t*j;
inc(j);
end;
t:=t/z;
inc(z);
end;
writeln(t:0:6);
end.