hdu 2108 Shape of HDU 判断是否为凸多边形
Shape of HDU
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
创业是需要地盘的,HDU向钱江肉丝高新技术开发区申请一块用地,很快得到了批复,据说这是因为他们公司研发的“海东牌”老鼠药科技含量很高,预期将占全球一半以上的市场。政府划拨的这块用地是一个多边形,为了描述它,我们用逆时针方向的顶点序列来表示,我们很想了解这块地的基本情况,现在请你编程判断HDU的用地是凸多边形还是凹多边形呢?
0 0 1 0 1 1 0 1
0
海东集团终于顺利成立了!后面的路,他们会顺顺利利吗?
欲知后事如何,且听下回分解——
#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+,M=1e6+,inf=1e9+;
const LL INF=1e18+,mod=1e9+; int sgn(double x)
{
if(fabs(x) < eps)return ;
if(x < )return -;
else return ;
}
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[];
memset(s,false,sizeof(s));
for(int i = ; i < n; i++)
{
s[sgn( (poly[(i+)%n]-poly[i])^(poly[(i+)%n]-poly[i]) )+] = true;
if(s[] && s[])return false;
}
return true;
}
int main ()
{
int n;
while(~scanf ( "%d", &n ) )
{
if(!n)break;
for(int i=; i<n; i++)
scanf ( "%lf%lf", &p[i].x, &p[i].y );
if(isconvex(p,n))printf("convex\n");
else printf("concave\n");
}
return ;
}
hdu 2108 Shape of HDU 判断是否为凸多边形的更多相关文章
- 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 ...
- HDU 2108 Shape of HDU (判断是不是凸多边形 叉乘)
Shape of HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tota ...
- hdu 2108 Shape of HDU (数学)
Shape of HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tota ...
- HDU 2108 Shape of HDU
题解:按照输入顺序依次将点连接起来,对于连续的三个点p0,p1,p2,令向量a=p1-p0,b=p2-p1 若是凸多边形,那么b相对于a一定是向逆时针方向旋转的 判断两向量的旋转方向,可以使用向量的叉 ...
- hdu 2108 Shape of HDU(判定是不是凸多边形)
#include <iostream> #include <algorithm> #include <cstring> #include <cstdio> ...
- Hdoj 2108.Shape of HDU 题解
Problem Description 话说上回讲到海东集团推选老总的事情,最终的结果是XHD以微弱优势当选,从此以后,"徐队"的称呼逐渐被"徐总"所取代,海东 ...
- 【计算几何初步-判断是否凸多边形】【HDU2108】Shape of HDU
Shape of HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...
- *HDU 2108 计算几何
Shape of HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tota ...
随机推荐
- The Little Prince-12/09
The Little Prince-12/09 今天中文书评+自述奥! 也许世界上也有五千朵和你一模一样的花,但只有你是我独一无二的玫瑰. ————喵喵喵,多么美妙的一句表白词呀! 时间会缓和所有的悲 ...
- java根据图片的url地址下载图片到本地
package com.daojia.haobo.aicircle.util; import sun.misc.BASE64Encoder; import java.io.*; import java ...
- OLED屏幕那些次像素有趣的排列方式
http://www.dzsc.com/data/2016-6-2/109856.html 我们今天的重点内容为倒数第二列内容的上半部分,也就是RGB排列和Pentile排列.在介绍OLED屏幕时候我 ...
- es6转es5在线工具
es6转es5在线工具:https://babeljs.io/repl/# 程序员常用在线工具:https://tool.lu/
- Python笔记 #19# 实现bpnn
代码编辑&解释工具:Jupyter Notebook 快速入门 形象说明BP神经网络的用法(图片来自推特): Bpnn类最主要的三个方法: initialize方法,用于设定神经网络的层数.各 ...
- Redis随笔-rename效率问题
背景 rename是redis中给key重命名命令,rename key newkey的意思就是将key重命名为newkey.大部分文档在介绍rename的时候只将它描述成一个时间复杂度为O(1)的命 ...
- python简说(九)函数
一.列表生成式 s =[1,2,3,4,5,6,7,8]for i in s: print(i+1)res = [ i+1 for i in s]res = [str(i) for i in s] 二 ...
- Python3 tkinter基础 event keysym 查看按键的按键名
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- POJ - 2421 Constructing Roads 【最小生成树Kruscal】
Constructing Roads Description There are N villages, which are numbered from 1 to N, and you should ...
- tp剩余未验证内容-4
关于pop-up被blocked的问题 首先 这个pop-up的功能叫 popup blocker , 它是浏览器(包括ff, chrome等) 自身 所内置 的一个功能, 不是 安装的外部 插件/或 ...