2017-03-10 20:57:16

#include <stdio.h>
#include <string>
#include <cmath>
#include <iostream>
using namespace std;
inline int read(){
int x=0,p=1;char ch=getchar();
while (ch<'0'||ch>'9'){if (ch=='-')p=-1;ch=getchar();}
while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
return x*p;
}
struct arr
{
int x,y;
void intput(){x=read();y=read();}
}edge[4];
arr r;
int find(arr a,arr b)
{
return (b.x-r.x)*(a.y-r.y)-(a.x-r.x)*(b.y-r.y);
}
int find1(arr a,arr b,arr c)
{
return min(a.x,b.x)<=c.x&&min(a.y,b.y)<=c.y&&max(a.x,b.x)>=c.x&&max(a.y,b.y)>=c.y;
}
int main()
{
edge[1].intput(); edge[2].intput(); edge[3].intput();
r.intput();
int m=0,t=0;
if (edge[1].x==r.x&&edge[1].y==r.y)
{
printf("4\n");
return 0;
}
if (edge[2].x==r.x&&edge[2].y==r.y)
{
printf("4\n");
return 0;
}
if (edge[3].x==r.x&&edge[3].y==r.y)
{
printf("4\n");
return 0;
}
m=find(edge[1],edge[2]);
if (m==0&&find1(edge[1],edge[2],r))
{
printf("3\n");
return 0;
}
t=m;
m=find(edge[2],edge[3]);
if (m==0&&find1(edge[2],edge[3],r))
{
printf("3\n");
return 0;
}
if (t>0&&m<0||t<0&&m>0)
{
printf("2\n");
return 0;
}
t=m;
m=find(edge[3],edge[1]);
if (m==0&&find1(edge[3],edge[1],r))
{
printf("3\n");
return 0;
}
if (t>0&&m<0||t<0&&m>0)
{
printf("2\n");
return 0;
}
printf("1\n");

}

• star
首页