Shape of HDU

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 5369    Accepted Submission(s): 2445

Problem Description
话说上回讲到海东集团推选老总的事情,最终的结果是XHD以微弱优势当选,从此以后,“徐队”的称呼逐渐被“徐总”所取代,海东集团(HDU)也算是名副其实了。

创业是需要地盘的,HDU向钱江肉丝高新技术开发区申请一块用地,很快得到了批复,据说这是因为他们公司研发的“海东牌”老鼠药科技含量很高,预期将占全球一半以上的市场。政府划拨的这块用地是一个多边形,为了描述它,我们用逆时针方向的顶点序列来表示,我们很想了解这块地的基本情况,现在请你编程判断HDU的用地是凸多边形还是凹多边形呢?
 
Input
输入包含多组测试数据,每组数据占2行,首先一行是一个整数n,表示多边形顶点的个数,然后一行是2×n个整数,表示逆时针顺序的n个顶点的坐标(xi,yi),n为0的时候结束输入。
 
Output
对于每个测试实例,如果地块的形状为凸多边形,请输出“convex”,否则输出”concave”,每个实例的输出占一行。
 
Sample Input
4
0 0 1 0 1 1 0 1
0
 
Sample Output
convex 海东集团终于顺利成立了!后面的路,他们会顺顺利利吗?
欲知后事如何,且听下回分解——
 
Author
lcy
 
Source
 
Recommend
lcy   |   We have carefully selected several similar problems for you:  1392 2109 2107 2111 2110 
 

判断   ai->ai+1(向量) 叉乘ai->ai+2(向量) 是否会小于0即可

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#define oo 0x13131313
#define maxn 10001
using namespace std;
int N;
int OK;
struct point {
double x,y;
};
point A[maxn];
void input()
{
OK=1;
for(int i=1;i<=N;i++)
{
scanf("%lf%lf",&A[i].x,&A[i].y);
}
}
void init()
{
freopen("a.in","r",stdin);
freopen("a.out","w",stdout);
}
void solve()
{
for(int i=1;i<=N;i++)
{
int j=i-1;int k=i+1;
if(k==N+1) k=1;
if(j==0) j=N;
if(((A[i].x-A[j].x)*(A[k].y-A[j].y)-(A[k].x-A[j].x)*(A[i].y-A[j].y))<0) OK=0;
}
}
int main()
{
//init();
while(cin>>N&&N)
{
input();
solve();
if(OK)
cout<<"convex"<<endl;
else cout<<"concave"<<endl;
}
return 0;
}

【计算几何初步-判断是否凸多边形】【HDU2108】Shape of HDU的更多相关文章

  1. hdu2108 Shape of HDU 极角排序判断多边形

    Problem Description 话说上回讲到海东集团推选老总的事情,最终的结果是XHD以微弱优势当选,从此以后,"徐队"的称呼逐渐被"徐总"所取代,海东 ...

  2. hdu 2108:Shape of HDU(计算几何,判断多边形是否是凸多边形,水题)

    Shape of HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  3. hrbustoj 1429:凸多边形(计算几何,判断点是否在多边形内,二分法)

    凸多边形 Time Limit: 2000 MS    Memory Limit: 65536 K Total Submit: 130(24 users)   Total Accepted: 40(1 ...

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

    Shape of HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Pro ...

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

    链接: http://acm.hdu.edu.cn/showproblem.php?pid=2108 http://acm.hust.edu.cn/vjudge/contest/view.action ...

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

    Shape of HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  7. 虚拟树研究-CheckBox初步判断只能在第一列

    //虚拟树研究-CheckBox初步判断只能在第一列 procedure TWindowsXPForm.XPTreeInitNode(Sender: TBaseVirtualTree; ParentN ...

  8. hrbustoj 1306:再遇攻击(计算几何,判断点是否在多边形内,水题)

    再遇攻击 Time Limit: 1000 MS    Memory Limit: 65536 K Total Submit: 253(37 users)   Total Accepted: 56(2 ...

  9. zoj 1081:Points Within(计算几何,判断点是否在多边形内,经典题)

    Points Within Time Limit: 2 Seconds      Memory Limit: 65536 KB Statement of the Problem Several dra ...

随机推荐

  1. servlet核心API的UML图

  2. SICP阅读笔记(一)

    2015-08-25   008   Foreword    QUOTE: I think that it's extraordinarily important that we in compute ...

  3. redhat换yum源

    根据redhat操作系统版本及位数,下载对应centos的版本及位数的这些包: yum-3.2.22-40.el5.centos.noarch.rpm yum-fastestmirror-1.1.16 ...

  4. (原)vs2013编译成静态库

    转载请注明出处: http://www.cnblogs.com/darkknightzh/p/5477664.html 1. 在“属性”-“配置属性”-“常规”-“配置类型”里面设置“静态库(.lib ...

  5. [Leetcode] Find the minimum in rotated sorted array

    我在Github上新建了一个解答Leetcode问题的Project, 大家可以参考, 目前是Java 为主,里面有leetcode上的题目,解答,还有一些基本的单元测试,方便大家起步. 题目: Su ...

  6. LP64是什么意思

    在64位机器上,如果int是32位,long是64位,pointer也是64位,那么该机器就是LP64的,其中的L表示Long,P表示Pointer,64表示Long和Pointer都是64位的.由于 ...

  7. CSS布局部分知识总结

    一 切图 通过一个周的切图练习,我发现只有亲自动手后才能通过问题不断加深技术,要熟练掌握HTML页面编写时候时PHOTOSHOP操作. 以下一些知识点在网络布局时也是很重要的. 1.ul标签在谷歌.火 ...

  8. PHP根据经纬度,计算2点之间的距离的2种方法

    计算地球表面2点之间的球面距离 /** * @param $lat1 * @param $lng1 * @param $lat2 * @param $lng2 * @return int */ fun ...

  9. Fatal error: Undefined class constant 'MYSQL_ATTR_USE_BUFFERED_QUERY' in D:\inetpub\vhosts\zenpty.com\httpdocs\includes\database

    打开php.ini配置文件,找到php_pdo_mysql.dll,如果前面有分号";"则表示该行被注释掉了,将分号去掉,保存,然后重启apache服务,重新访问页面,问题解决了.

  10. Python之路第十三天,高级(7)-详述数据库一对多,多对多表关系的设计以及如何查询

    一对多表设计和查询方法 #!/usr/bin/env python3 # Author: Zhangxunan from sqlalchemy import create_engine from sq ...