Pagini recente » Cod sursa (job #22930) | Cod sursa (job #2568626) | Cod sursa (job #2953520) | Cod sursa (job #1659893) | Cod sursa (job #44839)
Cod sursa(job #44839)
const
lim=25;
var
dez:array[1..lim] of real;
a,done:array[0..lim] of longint;
cate,i,j,n,k:longint;
t,sol:real;
{procedure calculeaza;
var
i:longint;
begin
t:=1;
for i:=1 to k do
t:=t*dez[a[i]];
sol:=sol+t;
inc(cate);
end;}
procedure doit(x:longint);
var
i:longint;
r:real;
begin
if (x>k) then
begin
{calculeaza;}
sol:=sol+t;
inc(cate);
exit;
end;
for i:=a[x-1]+1 to n do
if done[i]=0 then
begin
a[x]:=i;
done[i]:=1;
r:=t;
t:=t*dez[i];
doit(x+1);
t:=r;
done[i]:=0;
a[x]:=0;
end;
end;
begin
assign(input,'dezastru.in');
reset(input);
readln(n,k);
for i:=1 to n do read(dez[i]);
close(input);
t:=1;
doit(1);
sol:=sol/cate;
assign(output,'dezastru.out');
rewrite(output);
writeln(sol:0:6);
close(output);
end.