Read post
#include<iostream>
using namespace std;
class point
{
public:
double x;
double y;
};
double s(point o,point a,point b)//三角形的有向面积
{
return(((a.x-o.x)*(b.y-o.y)-(b.x-o.x)*(a.y-o.y))/2);
}
int main()
{
point p[60];
int n,m;
while (cin>>n>>m&&n!=0)
{
point temp;
int i;
for (i=1; i<=n; ++i)
cin>>p[i].x>>p[i].y;
int sum=0;
for (i=1; i<=m; ++i)
{
cin>>temp.x>>temp.y;
int j;
bool out=false;
for (j=1; j<=n-2; ++j)
if (s(p[n],p[j],p[j+1])*s(temp,p[j],p[j+1])<0)
out=true;
if (s(p[1],p[n-1],p[n])*s(temp,p[n-1],p[n])<0)
out=true;
if (s(p[2],p[1],p[n])*s(temp,p[1],p[n])<0)
out=true;
if (out) sum+=1;
else sum+=2;
}
cout<<sum<<endl;
}
return(0);
}
Reply
|