Nu aveti permisiuni pentru a descarca fisierul grader_test1.in
Cod sursa(job #1180303)
| Utilizator | Data | 30 aprilie 2014 14:43:53 | |
|---|---|---|---|
| Problema | Dezastru | Scor | 100 |
| Compilator | fpc | Status | done |
| Runda | Arhiva de probleme | Marime | 0.73 kb |
var n,k,i,j:longint;
a:array[0..30,0..30] of real;
b:array[0..30] of real;
function comb(n,k:byte):real;
var i:longint;
begin
comb:=1;
for i:=1 to n do
begin
comb:=comb*i;
if i<=n-k then comb:=comb/i;
if i<=k then comb:=comb/i;
end;
end;
begin
assign(input,'dezastru.in');
assign(output,'dezastru.out');
reset(input);
rewrite(output);
readln(n,k);
for i:=1 to n do
begin
read(b[i]);
a[i][0]:=1;
end;
a[0][0]:=1;
for i:=1 to k do
for j:=i to n do
a[j][i]:=a[j-1][i]+a[j-1][i-1]*b[j];
writeln(a[n][k]/comb(n,k):0:6);
close(input);
close(output);
{Totusi este trist in lume}
end.
