Note
The first sample corresponds to the picture:
The picture shows that you can get in the water under unfortunate circumstances only at turn at the point (1, 1). Thus, the answer is 1.
题意:给出一个多边形的所有点坐标(按顺序给),某人求顺时针走一圈有多少条边使他走进多边形内。
分析:这个人在顺时针走,如果连着的两条线段,是逆时针的,显然这个人就走到多边形内部去了
这个就用个叉积去判一判就好了。
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
const double eps = 1e-6;
const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
#define ll long long
#define CL(a,b) memset(a,b,sizeof(a))
#define lson (i<<1)
#define rson ((i<<1)|1)
#define MAXN 100010
struct node
{
int x,y;
}s[1010];
int chaji(node A, node B, node C)
{
return (A.x-B.x)*(C.y-B.y)-(C.x-B.x)*(A.y-B.y);
}
int main()
{
int n;
while(scanf("%d",&n)==1)
{
for(int i=0; i<=n; i++)
cin>>s[i].x>>s[i].y;
s[n+1].x = s[1].x;
s[n+1].y = s[1].y;
int ans = 0;
for(int i=1; i<=n; i++)
{
if(chaji(s[i-1], s[i], s[i+1]) < 0)
ans++;
}
cout<<ans<<endl;
}
return 0;
}