Page 165 - C:\Users\Admin\Desktop\Sach mem upweb\
P. 165
100 Problems & Solutions Trang 165
end;
procedure Calculator(n: Integer);
var
i, j: Integer;
begin
if Pred[n] = n - 2 then
begin
Ok[n] := True; Inc(lSum);
for i := Ind[n - 1] + 1 to Ind[n] do
for j := Ind[p[i] - 1] + 1 to Ind[p[i]] do Calculator(p[j])
end
else for i := Ind[n - 1] + 1 to Ind[n] do Calculator(p[i])
end;
procedure WriteOutput;
var
hFile: Text;
i: Integer;
sView: LongInt;
begin
Assign(hFile, Out);
Rewrite(hFile);
sView := View(p[1]);
Calculator(p[1]);
Writeln(hFile, lSum, ' ', sView);
for i := 1 to n do
if Ok[i] then Writeln(hFile, i);
Close(hFile);
end;
begin
ReadInput;
Prepare;
WriteOutput;
end.
=========================== The End ============================
Tin học & Nhà trường 100 Đề Toán - Tin học