Pagini recente » Cod sursa (job #81038) | Cod sursa (job #563434) | Cod sursa (job #2763934) | Cod sursa (job #2847506) | Cod sursa (job #39279)
Cod sursa(job #39279)
var a,c:array[0..25]of real;
d:array[0..25]of integer;
b:array[1..4194304]of real;
n,k,i,z,x:longint;
r:real;
procedure back(i:integer);
var j:integer;
begin
if i>k then
begin
z:=z+1;
b[z]:=1;
for j:=1 to k do b[z]:=b[z]*c[j];
exit;
end;
for j:=d[i-1] to n do
begin
if k-x>n-j+1 then break;
if a[j]=c[x] then continue;
x:=x+1;
d[x]:=j+1;
c[x]:=a[j];
back(i+1);
c[x]:=0;
d[x]:=0;
x:=x-1;
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]);
d[0]:=1;
z:=0;
back(1);
for i:=1 to z do
begin
r:=r+b[i];
end;
r:=r/z;
writeln(r:0:6);
close(output);
end.