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 ...
随机推荐
- 《C++ Primer 4th》读书笔记 第7章-函数
原创文章,转载请注明出处:http://www.cnblogs.com/DayByDay/p/3912413.html
- 翻译【ElasticSearch Server】第一章:开始使用ElasticSearch集群(1)
我们要做的第一件事是安装ElasticSearch.对于多数应用程序,您开始安装和配置,通常忘记这些步骤的重要性,直到发生了糟糕的事情.这章我们将广泛关注ElasticSearch的这部分.请注意本章 ...
- bjfu1164 Parity Game
简单规律题.首先想到的是,若01串中1有n个,则可以通过操作,使串中1的个数变为n-1.n-2……1.0个:第2个想到的是,如果n为奇数,可以通过操作,使串中1的个数最多变为n+1,而若n为偶数,则无 ...
- hdu 1544 水题
水题 /* * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> #i ...
- 【SQL server】安装和配置
(1)SQL sever 版本问题1: SQL sever 2000 .SQL sever 2005.SQL sever 2008 .SQL sever 2008 R2 安装的时候需要注意是SQL s ...
- 通过反汇编C语言小程序学习Liunx汇编语言
大家好! 我是来自山东师范大学的吴乐. 今天在<Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 ...
- C# 与 VC Dll 传输信息
考虑: 使用string类型传送: 在VC Dll中解析字符: 使用 string 类型将解析的类型传送到C#程序中: 建立VC解析的函数,提高代码可重用性
- Python字典方法copy()和deepcopy()的区别
from copy import deepcopy # import deepcopy模块 d = {} d['name'] = ['black', 'guts'] # d = {'name': [' ...
- (转)UML用例图总结
用例图主要用来描述“用户.需求.系统功能单元”之间的关系.它展示了一个外部用户能够观察到的系统功能模型图. [用途]:帮助开发团队以一种可视化的方式理解系统的功能需求. 用例图所包含的元素如下: 1. ...
- stdlib.h 头文件
stdlib 头文件即standard library标准库头文件.stdlib.h里面定义了五种类型.一些宏和通用工具函数. 类型例如size_t.wchar_t.div_t.ldiv_t和lldi ...