Pagini recente » Cod sursa (job #944032) | Cod sursa (job #1281280) | Cod sursa (job #85876) | Cod sursa (job #1762542) | Cod sursa (job #2328766)
#include <cstdio>
using namespace std;
int n,m;
int nr=0;
struct punct
{
int x,y;
}Vf[5005];
punct Ext;
void citire()
{
scanf("%d %d",&n,&m);
for(int i=0;i<n;i++)
scanf("%d %d",&Vf[i].x,&Vf[i].y);
}
float determ(int x,int y,punct a,punct b)
{
float f=((a.x-x)*(b.y-y)-(a.y-y)*(b.x-x));
return f;
}
void verif(int x,int y)
{
float f1,f2;
int cont=0;
for(int i=1;i<n;i++)
{
f1=determ(x,y,Vf[i-1],Ext);
f2=determ(x,y,Vf[i],Ext);
if(f1>=0 && f2<=0)
cont++;
else if(f1<=0 && f2>=0)
cont++;
}
if(cont%2!=0)
nr++;
}
int main()
{
Ext.x=60005;
Ext.y=60005;
freopen("poligon.in","r",stdin);
freopen("poligon.out","w",stdout);
citire();
int x,y;
for(int i=0;i<m;i++)
{
scanf("%d %d",&x,&y);
verif(x,y);
}
printf("%d",nr);
return 0;
}