标签:otto false queue opera size 编程 nsx comment stream
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
#pragma comment(linker, "/STACK:1024000000,1024000000") #include<iostream> #include<cstdio> #include<cmath> #include<string> #include<queue> #include<algorithm> #include<stack> #include<cstring> #include<vector> #include<list> #include<bitset> #include<set> #include<map> #include<time.h> using namespace std; #define LL long long #define pi (4*atan(1.0)) #define eps 1e-8 #define bug(x) cout<<"bug"<<x<<endl; const int N=1e5+10,M=1e6+10,inf=1e9+10; const LL INF=1e18+10,mod=1e9+7; int sgn(double x) { if(fabs(x) < eps)return 0; if(x < 0)return -1; else return 1; } struct Point { double x,y; Point() {} Point(double _x,double _y) { x = _x; y = _y; } Point operator -(const Point &b)const { return Point(x - b.x,y - b.y); } //叉积 double operator ^(const Point &b)const { return x*b.y - y*b.x; } //点积 double operator *(const Point &b)const { return x*b.x + y*b.y; } //绕原点旋转角度B(弧度值),后x,y的变化 void transXY(double B) { double tx = x,ty = y; x= tx*cos(B) - ty*sin(B); y= tx*sin(B) + ty*cos(B); } }; Point p[N]; bool isconvex(Point poly[],int n) { bool s[3]; memset(s,false,sizeof(s)); for(int i = 0; i < n; i++) { s[sgn( (poly[(i+1)%n]-poly[i])^(poly[(i+2)%n]-poly[i]) )+1] = true; if(s[0] && s[2])return false; } return true; } int main () { int n; while(~scanf ( "%d", &n ) ) { if(!n)break; for(int i=0; i<n; i++) scanf ( "%lf%lf", &p[i].x, &p[i].y ); if(isconvex(p,n))printf("convex\n"); else printf("concave\n"); } return 0 ; }
hdu 2108 Shape of HDU 判断是否为凸多边形
标签:otto false queue opera size 编程 nsx comment stream
原文地址:http://www.cnblogs.com/jhz033/p/7428214.html