hdu 2108 Shape of HDU(判定是不是凸多边形)

Posted jaydenouyang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hdu 2108 Shape of HDU(判定是不是凸多边形)相关的知识,希望对你有一定的参考价值。

 1 #include <iostream>
 2 #include <algorithm>
 3 #include <cstring>
 4 #include <cstdio>
 5 #include <string>
 6 #include <map>
 7 #include <cmath>
 8 #include <vector>
 9 
10 #define Faster ios::sync_with_stdio(false),cin.tie(0)
11 #define Read freopen("in.txt","r",stdin),freopen("out.txt","w",stdout)
12 #define Close fclose(stdin),fclose(stdout)
13 const int maxn = 1e5 + 5;
14 using namespace std;
15 const int MOD = 1e9+7;
16 typedef long long ll;
17 
18 const double eps = 1e-6;
19 #define _sign(x)((x)>eps?1:((x)<-eps?2:0))
20 
21 
22 struct point
23 {
24     double x,y;
25 }p[maxn];
26 
27 double xmult(point p1,point p2,point p0) { 
28     return(p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y); 
29 }
30 
31 int is_convex(int n) { 
32     int i,s[3]={1,1,1}; 
33     for (i=0;i<n&&s[1]|s[2];i++) 
34         s[_sign(xmult(p[(i+1)%n],p[(i+2)%n],p[i]))] = 0; 
35     return s[1]|s[2]; 
36 }
37 
38 int main(){
39     Faster;
40     int n;
41     while(cin >> n){
42         if(n == 0)
43             break;
44         for(int i = 0;i < n;i++){
45             cin >> p[i].x >> p[i].y;
46         }
47         if(is_convex(n)){
48             cout << "convex" << endl;
49         }
50         else
51             cout << "concave" << endl;
52     }
53     return 0;
54 }

 

以上是关于hdu 2108 Shape of HDU(判定是不是凸多边形)的主要内容,如果未能解决你的问题,请参考以下文章

HDU 2108 Shape of HDU

HDU 2108 Shape of HDU (判断是不是凸多边形 叉乘)

hdu 2108 Shape of HDU 判断是否为凸多边形

(hdu step 7.1.1)Shape of HDU(推断一个多边形是否是凸多边形)

寒假作业,shape of HDU

HDU 2444 The Accomodation of Students 二分图判定+最大匹配