题意:给出一个n边形,并且从左下角开始顺时针给出点坐标,求凹进去的地方的个数。
向量叉积算出方向,统计一下就完了。
/* Footprints In The Blood Soaked Snow */
#include <cstdio>
#include <utility>
#include <algorithm>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int maxn = 1005;
int n;
pii p[maxn];
int main() {
scanf("%d", &n);
for(int i = 1; i <= n + 1; i++) scanf("%d%d", &p[i].first, &p[i].second);
p[0] = p[n];
int ans = 0;
for(int i = 1; i <= n; i++) {
int x1 = p[i - 1].first, y1 = p[i - 1].second;
int x2 = p[i].first, y2 = p[i].second;
int x3 = p[i + 1].first, y3 = p[i + 1].second;
LL costh = (x2 - x1) * (y3 - y2) - (x3 - x2) * (y2 - y1);
if(costh > 0) ans++;
}
printf("%d\n", ans);
return 0;
}