Pagini recente » Cod sursa (job #1653762) | Cod sursa (job #1608654) | Cod sursa (job #56351) | Cod sursa (job #1258817) | Cod sursa (job #571)
Cod sursa(job #571)
program hio;
type el=record
xx,yy:longint;
end;
ta=array [1..1000] of el;
var f:text;
vf,inf:ta;
n,m,cont,i,j:integer;
d1,d2,ps,suma,co,si,u:real;
function dist(x1,x2,y1,y2:integer):real;
begin
dist:=sqrt(sqr(x1-x2)+sqr(y1-y2));
end;
begin {pp}
assign(f,'poligon.in');reset(f);
readln(f,n,m);
for i:=1 to n do
readln(f,vf[i].xx,vf[i].yy);
vf[n+1].xx:=vf[1].xx;
vf[n+1].yy:=vf[1].yy;
for i:=1 to m do
readln(f,inf[i].xx,inf[i].yy);
close(f);
cont:=0;
for i:=1 to m do
begin
suma:=0;
for j:=1 to n do
begin
d1:=dist(inf[i].xx,vf[j].xx,inf[i].yy,vf[j].yy);
d2:=dist(inf[i].xx,vf[j+1].xx,inf[i].yy,vf[j+1].yy);
ps:=(vf[j].xx-inf[i].xx)*(vf[j+1].xx-inf[i].xx)+
(vf[j].yy-inf[i].yy)*(vf[j+1].yy-inf[i].yy);
co:=ps/(d1*d2);
si:=sqrt(1-(co*co));
if (co=0) then u:=pi/2
else u:=arctan(si/co);
if (si=0) and (co=-1) then u:=pi;
suma:=suma+u;
end;
if abs(suma-2*pi)<0.00000001 then inc(cont);
end;
assign(f,'poligon.out');rewrite(f);
write(f,cont);
close(f);
end.