【计算几何初步-判断是否凸多边形】【HDU2108】Shape of HDU
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
创业是需要地盘的,HDU向钱江肉丝高新技术开发区申请一块用地,很快得到了批复,据说这是因为他们公司研发的“海东牌”老鼠药科技含量很高,预期将占全球一半以上的市场。政府划拨的这块用地是一个多边形,为了描述它,我们用逆时针方向的顶点序列来表示,我们很想了解这块地的基本情况,现在请你编程判断HDU的用地是凸多边形还是凹多边形呢?
4
0 0 1 0 1 1 0 1
0
convex 海东集团终于顺利成立了!后面的路,他们会顺顺利利吗?
欲知后事如何,且听下回分解——
判断 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的更多相关文章
- hdu2108 Shape of HDU 极角排序判断多边形
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)Tota ...
- hrbustoj 1429:凸多边形(计算几何,判断点是否在多边形内,二分法)
凸多边形 Time Limit: 2000 MS Memory Limit: 65536 K Total Submit: 130(24 users) Total Accepted: 40(1 ...
- hdu 2108 Shape of HDU 判断是否为凸多边形
Shape of HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Pro ...
- hdu 2108 Shape of HDU【判断多边形是否是凸多边形模板】
链接: http://acm.hdu.edu.cn/showproblem.php?pid=2108 http://acm.hust.edu.cn/vjudge/contest/view.action ...
- HDU 2108 Shape of HDU (判断是不是凸多边形 叉乘)
Shape of HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tota ...
- 虚拟树研究-CheckBox初步判断只能在第一列
//虚拟树研究-CheckBox初步判断只能在第一列 procedure TWindowsXPForm.XPTreeInitNode(Sender: TBaseVirtualTree; ParentN ...
- hrbustoj 1306:再遇攻击(计算几何,判断点是否在多边形内,水题)
再遇攻击 Time Limit: 1000 MS Memory Limit: 65536 K Total Submit: 253(37 users) Total Accepted: 56(2 ...
- zoj 1081:Points Within(计算几何,判断点是否在多边形内,经典题)
Points Within Time Limit: 2 Seconds Memory Limit: 65536 KB Statement of the Problem Several dra ...
随机推荐
- 一些基础的.net用法
一.using 用法 using 别名设置 using 别名 = System.web 当两个不同的namespace里有同名的class时.可以用 using aclass = namespace1 ...
- Js Json 互转
推荐: //js对象转换为 JSON 文本 var text = '[{"id":1,"name":"C","size" ...
- 《JavaScript 闯关记》之原型及原型链
原型链是一种机制,指的是 JavaScript 每个对象都有一个内置的 __proto__ 属性指向创建它的构造函数的 prototype(原型)属性.原型链的作用是为了实现对象的继承,要理解原型链, ...
- J2EE 中 The function valueOf must be used with a prefix when a default namespace is not specified 错误
jsp页面中,JSTL El表达式字符串比较常用方法 fn:contains 判断字符串是否包含另外一个字符串 <c:if test="${fn:contains(name, sear ...
- MJExtension(JSON到数据模型的自动转换)
整理自:http://www.jianshu.com/p/93c242452b9b. 1.MJExtension的功能 字典-->模型 模型-->字典 字典数组-->模型数组 模型数 ...
- appStore应用发布流程
原文转自: http://blog.sina.com.cn/s/blog_68661bd801019uzd.html 首先确定帐号是否能发布, https://developer.appl ...
- js实现页面图片加载进度条
//html <div id="loading" class="loading"> <div class="load"&g ...
- <%@ include file=""%>与<jsp:include page=""/>区别
jsp页面是把include指令元素(<%@ include file=""%>)所指定的页面的实际内容(也就是代码段)加入到引入它的jsp页面中,合成一个文件后被js ...
- 【4】项目结构+基本的Tornado服务
项目地址: Blog 简单的tornado服务分支: simple 项目结构 创建对应的文件夹并测试一个最简单的功能 main.py #!/usr/bin/env python # coding:ut ...
- C++----练习--bool类型作为特别的int要区别对待
1.程序源码: #include<iostream> int main() { ; int i=condition; std::cout<<i<<std::endl ...