Pagini recente » Cod sursa (job #1260655) | Cod sursa (job #549805) | Cod sursa (job #2191957) | Cod sursa (job #88139) | Cod sursa (job #73203)
Cod sursa(job #73203)
Program dezastru;
Var f:text;
i,k,n,m,p:longint;
s,pp:real;
x:array[1..8000] of byte;
a:array[1..8000] of real;
function cond(k:longint):boolean;
begin
cond:=true;
for i:=1 to k-1 do if x[i]=x[k] then cond:=false;
end;
Begin
assign(f,'dezastru.in');
reset(f);
readln(f,n,m);
for i:=1 to n do
read(f,a[i]);
close(f);
k:=1;
x[k]:=0;
s:=0.0;
while k>0 do
begin
p:=0;
while (x[k]<n) and (p=0) do
begin
x[k]:=x[k]+1;
if cond(k) then p:=1;
end;
pp:=1.0;
if p=0 then k:=k-1
else if k=m then begin for i:=1 to m do pp:=pp*a[x[i]]; s:=s+pp/(n*(n-1)); end
else begin k:=k+1; x[k]:=0; end;
end;
assign(f,'dezastru.out');
rewrite(f);
Writeln(f,s:0:6);
close(f);
End.