| 记录编号 |
384652 |
评测结果 |
AAWAWWWWWW |
| 题目名称 |
2635.[天梯赛PAT]长城 |
最终得分 |
30 |
| 用户昵称 |
cstdio |
是否通过 |
未通过 |
| 代码语言 |
C++ |
运行时间 |
0.435 s |
| 提交时间 |
2017-03-18 21:03:39 |
内存使用 |
1.84 MiB |
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long LL;
const int SIZEN=100010;
class Point{
public:
LL x,y;
Point(LL _x=0,LL _y=0):x(_x),y(_y){}
Point operator - (const Point &b){
return Point(x-b.x,y-b.y);
}
friend LL crs (const Point &a,const Point &b){
return a.x*b.y-a.y*b.x;
}
};
int N;
Point P[SIZEN];
void work(void){
//scanf("%d",&N);
//for(int i=1;i<=N;i++) scanf("%lld%lld",&P[i].x,&P[i].y);
cin>>N;
for(int i=1;i<=N;i++) cin>>P[i].x>>P[i].y;
int ans=0;
Point now=P[1];
for(int i=2;i<N;i++){
if(crs(P[i]-now,P[i+1]-P[i])>0){
now=P[i];
ans++;
}
}
printf("%d\n",ans);
}
int main(){
freopen("gfw.in","r",stdin);
freopen("gfw.out","w",stdout);
work();
return 0;
}