GIẢI ĐỀ THI TIN HỌC TRẺ KHÔNG CHUYÊN TỈNH BÌNH ĐịNH
NĂM 2006
(Giải theo yêu cầu của đề Tỉnh Bình Định - Nguyễn Thị Hoa)
Bài 1. (Giải cho nhiều bộ Input, còn đề thi chỉ minh họa cho một Input)
BAI1.INP BAI1.OUT
6
7
5
6
1
3
4
**********************
5
3
5
6
4
2
**********************
8
7
6
4
5
8
2
1
9
*********************
2
until i>j;
if l<j then sort(l,j);
if i<r then sort(i,r);
End;
Begin {sap xep tang dan}
sort(1,N);
maso :=1;
{tim ma nho nhat}
for i:=1 to n-1 do
if a[i+1]-a[i] >=2 then
begin maso:= a[i]+1;write(maso);break;end;
End;
Procedure Xuat;
Begin
writeln(f2,maso);
writeln(f2,sao);
End;
BEGIN
assign(f1,fi); reset(f1);
assign(f2,fo);rewrite(f2);
while Not(EOF(f1)) do
Begin
Nhap;Xuli;Xuat;
End;
close(f1);close(f2);
END.
Bài 2. (Giải cho nhiều bộ Input, còn đề thi chỉ minh họa cho một Input)
BAI2.INP BAI2.OUT
29 4
3 5 7 11
conlai:=m - m1;
for j:=1 to n do
if conlai=a[j] then
begin
b[j]:=b[j]+1; break;
end;
s:=s+b[j];
end;
end;
End;
Procedure Xuat;
Begin
writeln(f2,s);
for i:=1 to n do write(f2,b[i],' ');
writeln(f2);
writeln(f2,sao);
End;
BEGIN
assign(f1,fi);reset(f1);
assign(f2,fo);rewrite(f2);
while Not(eof(f1)) do
Begin
NHAP;
XULI;
XUAT;
End;
close(f1);close(f2);
END.
--------------------------------------------