Pagini recente » Cod sursa (job #785919) | Cod sursa (job #1784487) | Cod sursa (job #2814568) | Cod sursa (job #938056) | Cod sursa (job #574440)
Cod sursa(job #574440)
var a:array[1..25] of real;
x:array[0..25] of byte;
i,n,k,p,y,z,q:longint;
s,pr:real;
procedure back(t:integer);
var i:integer;
begin
for i:=x[t-1]+1 to n do
begin
x[t]:=i;
pr:=pr*a[x[t]];
if t=k then s:=s+pr
else back(t+1);
pr:=pr/a[x[t]];
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:=0;pr:=1;
back(1);
for i:=n downto 1 do
begin
s:=s/i;
if i<=k then s:=s*i;
if i<=n-k then s:=s*i;
end;
write(s:0:6);
end.