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 ...
随机推荐
- QT -- plan
QT -- 跨平台的 C++ 图形用户界面 应用程序框架 GUI介绍框架项目文件 .pro第一个QT (hello QT)父窗口 和 子窗口的区别(控件,部件,构件)信号 和 槽(信号的处理 ...
- Linux 用户管理【UID和GID】
Linux 用户和用户组管理 Linux系统是一个多用户多任务的分时操作系统,任何一个要使用系统资源的用户,都必须首先向系统管理员申请一个账号,然后以这个账号的身份进入系统. 用户的账号一方面可以帮助 ...
- 关于reduce输出write方法
关于hadoop一些自定义输出 code>OutputFormat</code> describes the output-specification for a * Map-Red ...
- UVA - 748 Exponentiation
Problems involving the computation of exact values of very large magnitude and precision are common. ...
- An Example of How Oracle Works
Oracle是怎么工作的,摘自Oracle 9i的官方文档 The following example describes the most basic level of operations tha ...
- centos/rhel 7 几个最重要变化(systemd,firewalld,networkmanager,文件系统)
详细参考:https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administra ...
- mybatis 3.2.*打印sql结果集
虽然可以写个interceptor记录下,但是总归没有log4j来的自然.一段时间不查问题,总是要忘了,记录下: 在mybatis 3.2.*中,可以在log4j中如下配置: log4j.logger ...
- Ubuntu mysql数据库导入sql文件
在阿里云Ubuntu系统导入sql数据库文件 首先linux 下查看mysql相关目录 root@ubuntu14:~# whereis mysql mysql: /usr/bin/mysql--- ...
- indexOf()/equals/contains
indexOf():对大小写敏感定义:返回某个指定字符串值在字符串中首次出现位置用法:返回字符中indexof(string)中字串string在父串中首次出现的位置,从0开始!没有返回-1:方便判断 ...
- 什么是ip地址,什么是私有地址
ip地址链接:https://jingyan.baidu.com/article/f96699bbf23089894e3c1be7.html 私有地址链接:https://baike.baidu.co ...