poj 1696

贪心+计算几何(叉点积)

个人认为本体用贪心解释最合理,我就是用贪心思考的此题

代码些的太挫啦

#include 
#include 
#include 
#include 
#include  
using namespace std;
const int maxn=55;
int m,n;
int vis[maxn];
int path[maxn];
struct Point
{
	int x,y;
	Point(int x=0,int y=0):x(x),y(y) { }
};
struct Plant
{
	Point po;
	int ind;
};
struct seg
{
	Point u,v;
};
Plant pla[maxn];
int cross(Point a,Point b,Point c,Point d)
{
   return (b.x-a.x)*(d.y-c.y)-(b.y-a.y)*(d.x-c.x);	
}
int judge(Point a,Point b,Point c,Point d)
{
	int c1=cross(a,b,a,c),c2=cross(a,b,a,d),
		c3=cross(c,d,c,a),c4=cross(c,d,c,b);
	if(c1*c2<0&&c3*c4<0) return 1;
	else return 0;
}
int dot(Point a,Point b,Point c,Point d) { return (b.x-a.x)*(d.x-c.x)+(b.y-a.y)*(d.y-c.y); }
double length(Point a,Point b) { return sqrt(double(dot(a,b,a,b))); }
double Angle(Point a,Point b,Point c)
{
	return acos(dot(a,b,b,c)/length(a,b)/length(b,c));
}
int main()
{
	scanf("%d",&m);
	while(m--)
	{
		scanf("%d",&n);
		int i;
		int miny=1000,minx=1000,start;
		seg s[maxn];
		int top=0;
		for(i=0;i


 

你可能感兴趣的:(几何)