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 }

原文地址:https://www.cnblogs.com/jaydenouyang/p/9159402.html

时间: 2024-10-13 06:43:53

hdu 2108 Shape of HDU(判定是不是凸多边形)的相关文章

hdu 2108 Shape of HDU (数学)

Shape of HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5059    Accepted Submission(s): 2294 Problem Description 话说上回讲到海东集团推选老总的事情,最终的结果是XHD以微弱优势当选,从此以后,"徐队"的称呼逐渐被"徐总"所取代,海东集

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

Shape of HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Description 话说上回讲到海东集团推选老总的事情,最终的结果是XHD以微弱优势当选,从此以后,“徐队”的称呼逐渐被“徐总”所取代,海东集团(HDU)也算是名副其实了.创业是需要地盘的,HDU向钱江肉丝高新技术开发区申请一块用地,很快得到了批复,据说这是因为他们公司研发的“海东牌”

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

Shape of HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5575    Accepted Submission(s): 2531 Problem Description 话说上回讲到海东集团推选老总的事情,最终的结果是XHD以微弱优势当选,从此以后,“徐队”的称呼逐渐被“徐总”所取代,海东集团(HDU)也算是名副其实了.

hdu 2108 Shape of HDU【判断多边形是否是凸多边形模板】

#include<stdio.h> #include<math.h> const int maxn = 100000; 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); } }p[maxn]; double eps =

HDU 2108 Shape of HDU

题目链接: http://acm.split.hdu.edu.cn/showproblem.php?pid=2108 Problem Description 话说上回讲到海东集团推选老总的事情,最终的结果是XHD以微弱优势当选,从此以后,“徐队”的称呼逐渐被“徐总”所取代,海东集团(HDU)也算是名副其实了.创业是需要地盘的,HDU向钱江肉丝高新技术开发区申请一块用地,很快得到了批复,据说这是因为他们公司研发的“海东牌”老鼠药科技含量很高,预期将占全球一半以上的市场.政府划拨的这块用地是一个多边

HDOJ 2108 Shape of HDU(凸包问题)

Shape of HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5984    Accepted Submission(s): 2745 Problem Description 话说上回讲到海东集团推选老总的事情,最终的结果是XHD以微弱优势当选,从此以后,"徐队"的称呼逐渐被"徐总"所取代,海东

HDU2108 Shape of HDU(判定凸多边形-模板)

Shape of HDU Problem Description 话说上回讲到海东集团推选老总的事情,最终的结果是XHD以微弱优势当选,从此以后,"徐队"的称呼逐渐被"徐总"所取代,海东集团(HDU)也算是名副其实了. 创业是需要地盘的,HDU向钱江肉丝高新技术开发区申请一块用地,很快得到了批复,据说这是因为他们公司研发的"海东牌"老鼠药科技含量很高,预期将占全球一半以上的市场.政府划拨的这块用地是一个多边形,为了描述它,我们用逆时针方向的顶点序

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

题目: Shape of HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 159 Accepted Submission(s): 97   Problem Description 话说上回讲到海东集团推选老总的事情,最终的结果是XHD以微弱优势当选,从此以后."徐队"的称呼逐渐被"徐总"所代替,海东集团(

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

题目: Shape of HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 159 Accepted Submission(s): 97   Problem Description 话说上回讲到海东集团推选老总的事情,最终的结果是XHD以微弱优势当选,从此以后,"徐队"的称呼逐渐被"徐总"所取代,海东集团(