Pagini recente » Cod sursa (job #2382766) | Cod sursa (job #1019096) | Cod sursa (job #2413824) | Cod sursa (job #1729814) | Cod sursa (job #639830)
Cod sursa(job #639830)
var s:array[0..26] of byte;
p:array[0..26] of real;
t,c:real;
i,k,n,nf:longint;
o,d:text;
function valid(y:longint):boolean;
var i:longint;
begin
valid:=true;
for i:=1 to y-1 do if s[i]=s[y] then begin valid:=false;break; end;
end;
procedure arnj(j:longint);
var ic:longint;
begin
if j=k+1 then begin
c:=p[s[1]];
for i:=2 to k do c:=c*p[s[i]];
t:=t+c/nf;
end
else for ic:=1 to n do
begin
s[j]:=ic;
if valid(j) then arnj(j+1);
end;
end;
begin
t:=0;nf:=1;
assign(d,'dezastru.in');assign(o,'dezastru.out');
reset(d);rewrite(o);
read(d,n);read(d,k);
for i:=2 to n do nf:=nf*i;
for i:=1 to n do read(d,p[i]);
arnj(1);
writeln(o,t:7:6);
close(d);close(o);
end.