分析:因为是凸多边形,所以只要对每条边求一下叉积即可.
设有向量P和Q则它们的叉积PXQ有以下性质:
1.PXQ>0 时,则P在Q的顺时针方向;
2.PXQ<0 时,则P在Q的逆时针方向;
3.PXQ=0 时,则P和Q共线,可能同向,也可能是反向;
#include
#include
#include
#include
#include
#include
#include
using namespace std;
const int maxn=100000;
struct point{
int x,y;
void read(){
cin>>x>>y;
}
}rt,f[maxn];
double cross(point p0,point p1,point p2){///叉积
return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y);
}
int main(){
int n;
while(cin>>n){
rt.read();
for(int i=0;i
f[i].read();
f[n]=f[0];
bool ok=true;
for(int i=0;i
if(cross(f[i],f[i+1],rt)<0){///在边的外部
ok=false; break;
}
if(ok) puts("Yes");
else puts("No");
}
return 0;
}