hdu 5563 Clarke and five-pointed star 水题
Clarke and five-pointed star
Time Limit: 20 Sec
Memory Limit: 256 MB
题目连接
http://acm.hdu.edu.cn/showproblem.php?pid=5563
Description
Clarke is a patient with multiple personality disorder. One day, Clarke turned into a learner of geometric.
When he did a research with polygons, he found he has to judge if the polygon is a five-pointed star at many times. There are 5 points on a plane, he wants to know if a five-pointed star existed with 5 points given.
Input
The first line contains an integer T(1≤T≤10), the number of the test cases.
For each test case, 5 lines follow. Each line contains 2 real numbers xi,yi(−109≤xi,yi≤109), denoting the coordinate of this point.
Output
Two numbers are equal if and only if the difference between them is less than 10−4.
For each test case, print Yes if they can compose a five-pointed star. Otherwise, print No. (If 5 points are the same, print Yes. )
Sample Input
2
3.0000000 0.0000000
0.9270509 2.8531695
0.9270509 -2.8531695
-2.4270509 1.7633557
-2.4270509 -1.7633557
3.0000000 1.0000000
0.9270509 2.8531695
0.9270509 -2.8531695
-2.4270509 1.7633557
-2.4270509 -1.7633557
Sample Output
Yes
No
HINT
题意
给你五个点,问你是否能够构成一个正五边形,精度要求1e-4
题解:
直接判断是否有五条边相同,是否有五条对角线长度相同就好了
代码
#include<iostream>
#include<stdio.h>
#include<map>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
const double eps = 1e-;
struct node
{
double x,y;
};
node p[];
vector<double> Q;
double dis(node a,node b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
int is_equal(double x,double y)
{
return fabs(x-y)<eps;
}
map<long long,int> H;
int main()
{
int t;scanf("%d",&t);
for(int cas=;cas<=t;cas++)
{
H.clear();
Q.clear();
for(int i=;i<;i++)
scanf("%lf%lf",&p[i].x,&p[i].y);
for(int i=;i<;i++)
{
for(int j=i+;j<;j++)
{
Q.push_back(dis(p[i],p[j]));
}
}
int flag = ;
sort(Q.begin(),Q.end());
for(int i=;i<Q.size();i++)
{
long long p = (100000.0*Q[i])*1LL;
if(H[p]==)
{
H[p]++;
flag++;
}
else
H[p]++;
}
if(flag>)
{
printf("No\n");
continue;
}
long long p1 = 1LL*(100000.0*Q[]);
long long p2 = 1LL*(100000.0*Q[]);
if(H[p1]==)
{
printf("Yes\n");
continue;
}
if(H[p1]!=&&H[p2]!=)
{
printf("No\n");
continue;
}
printf("Yes\n");
}
}
hdu 5563 Clarke and five-pointed star 水题的更多相关文章
- HDU 5832 A water problem(某水题)
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...
- hdu 2393:Higher Math(计算几何,水题)
Higher Math Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- <hdu - 3999> The order of a Tree 水题 之 二叉搜索的数的先序输出
这里是杭电hdu上的链接:http://acm.hdu.edu.cn/showproblem.php?pid=3999 Problem Description: As we know,the sha ...
- HDOJ/HDU 1256 画8(绞下思维~水题)
Problem Description 谁画8画的好,画的快,今后就发的快,学业发达,事业发达,祝大家发,发,发. Input 输入的第一行为一个整数N,表示后面有N组数据. 每组数据中有一个字符和一 ...
- hdu 1164:Eddy's research I(水题,数学题,筛法)
Eddy's research I Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- HDU ACM 1073 Online Judge ->字符串水题
分析:水题. #include<iostream> using namespace std; #define N 5050 char a[N],b[N],tmp[N]; void Read ...
- hdu 1754 I Hate It(线段树水题)
>>点击进入原题测试<< 思路:线段树水题,可以手敲 #include<string> #include<iostream> #include<a ...
- HDU 1029 Ignatius and the Princess IV --- 水题
HDU 1029 题目大意:给定数字n(n <= 999999 且n为奇数 )以及n个数,找出至少出现(n+1)/2次的数 解题思路:n个数遍历过去,可以用一个map(也可以用数组)记录每个数出 ...
- HDU 5583 Kingdom of Black and White 水题
Kingdom of Black and White Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showpr ...
随机推荐
- MySQL基础之第2章 Windows平台下安装与配置MySQL
2.1.msi安装包 2.1.1.安装 特别要注意的是,安装前要删除原来的my.ini和原来的data目录,改名也行,不然在最后一步会“apply security settings”报个1045错误 ...
- 【转】SDP file
SDP file Introduction The Session Description Protocol (SDP) is a format for describing the initiali ...
- C# 中LinkLabel的简单使用
界面中加入一个LinkLabel控件
- c# 进行AE开发时,如何在地图上定位出一个点
一.文本形式的气泡提示框 由于本人是初学,所以具体的含义尚未弄清楚,直接给出代码吧!
- Long Dominoes(ZOJ 2563状压dp)
题意:n*m方格用1*3的方格填充(不能重叠)求有多少种填充方法 分析:先想状态,但想来想去就是觉得不能覆盖所有情况,隔了一天,看看题解,原来要用三进制 0 表示横着放或竖放的最后一行,1表示竖放的中 ...
- [Hive - Tutorial] Data Units 数据存储单位
Data Units In the order of granularity - Hive data is organized into: 数据库.表.分区.桶 Databases: Namespac ...
- Spark系列(六)Master注册机制和状态改变机制
各组件的注册流程如下图: 注册机制源码说明: 入口:org.apache.spark.deploy.master文件下的receiveWithLogging方法中的case RegisterAppli ...
- CSS布局基础
(初级)css布局 一.单列布局1.基础知识块级元素 div p ul li dl dt 行级元素 img span input strong同一行显示.无换行2.盒子模型盒子模型 (边框border ...
- Android与Mysql服务器通信
需求:在手机端读取蓝牙传输过来的数据,然后发送到mysql 安卓前期版本可以直接使用mysql connector, 现在只能通过访问url传递数据了. 服务器端写php脚本,接受发送过来的url请求 ...
- 自己实现Single LinkedList
My_Single_LinkedList 分4个部分实现(CRUD - 增删改查). 首先要有一个Node(节点类) class Node { public int val; public Node ...