Thu Sep 06, 2012 3:51 pm
Admin Giải bài kiểm tra hồi sáng
Link : [You must be registered and logged in to see this link.]
- Code:
Const fi='bt1.inp'; fo='bt1.out';
Type diem=Record
x,y:Integer;
End;
Var A,B,C:Diem;ymax,ymin,xmax,xmin:Integer;
AA:array[1..3] Of diem;
f,g:text;
Procedure doctep;
Var i:Integer;
Begin
xmax:=0;xmin:=maxint;
ymin:=maxint;ymax:=0;
Assign(f,fi);
Reset(f);
For i:=1 to 3 do
Begin
Readln(f,aa[i].x,aa[i].y);
If aa[i].x > xmax then xmax:=aa[i].x;
If aa[i].x < xmin then xmin:=aa[i].x;
If aa[i].y > ymax then ymax:=aa[i].y;
If aa[i].y < ymin then ymin:=aa[i].y;
End;
A:=aa[1];B:=aa[2];c:=aa[3];
Close(f);
Assign(g,fo);
Rewrite(g);
End;
Function Line(M1,A1,B1:diem):Integer;
Begin
Line:=(B1.y-M1.y)*(A1.x-M1.x)-(A1.y-M1.y)*(B1.x-M1.x);
End;
Function nt(T1:diem):boolean;
Begin
nt:=false;
If (Line(T1,A,B)*Line(C,A,B) > 0 ) and
(Line(T1,A,C)*Line(B,A,C) > 0 ) and
(Line(T1,B,C)*Line(A,B,C) > 0 ) then
nt:=true;
End;
Procedure xuly;
Var s,i,j:Integer;TT:diem;
Begin
s:=0;
For i:=xmin to xmax do
For j:=ymin to ymax do
Begin
TT.x:=i;TT.y:=j;
If nt(TT) then inc(s);
TT.x:=0;TT.y:=0;
End;
Writeln(g,s:3);
End;
Begin
doctep;
xuly;
Close(g);
End.
Link : [You must be registered and logged in to see this link.]