HDU_5563Clarke and five-pointed star
Clarke and five-pointed star
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 156 Accepted Submission(s): 88
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.
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.
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.
)
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
Yes
NoHint
/*
*题目大意:给你五个点的坐标、要求判断是否可以组成五角星
*算法分析:注意在五点相同时候为YES,否则判断是否存在有两组五条相等的边, 存在则YES,否则NO
*/ #include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std; struct node{
double x, y;
}a[5]; int panDuan(double a, double b) {
if (fabs(a-b)<=1e-4)
return 1;
return 0;
} double juLi(double x1, double y1, double x2, double y2) {
return (double)(x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);
} int main() {
int t;
cin >> t;
while (t --) {
int flag = 0;
memset(a, 0, sizeof(a));
for (int i = 0; i<5; i++)
cin >> a[i].x >> a[i].y;
for (int i = 0; i<4; i++) {
if (panDuan(a[i].x, a[i+1].x) == 0 || panDuan(a[i].y, a[i+1].y) == 0)
flag = 1;
}
if (flag == 0)
cout << "Yes" << endl;
else {
flag = 0;
double ans1;
double ans = juLi(a[0].x, a[0].y, a[1].x, a[1].y);
for (int i = 0; i<5; i++) {
for (int j = i+1; j<5; j++) {
if (fabs(juLi(a[i].x, a[i].y, a[j].x, a[j].y) - ans) > 1e-4)
ans1 = juLi(a[i].x, a[i].y, a[j].x, a[j].y);
}
}
int flag1 = 0;
//cout << ans << endl<< endl;
for (int k = 0; k<5; k++) {
for (int l = k+1; l<5; l++) {
//cout << juLi(a[k].x, a[k].y, a[l].x, a[l].y) << endl << endl;
if (panDuan(juLi(a[k].x, a[k].y, a[l].x, a[l].y), ans) == 1)
flag ++ ;
if (panDuan(juLi(a[k].x, a[k].y, a[l].x, a[l].y), ans1) == 1)
flag1 ++ ;
}
}
//cout << flag << endl;
if (flag == 5 && flag1 == 5)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
} return 0;
}
HDU_5563Clarke and five-pointed star的更多相关文章
- all unicode
Unicode Chart Range Decimal Name 0x0000-0x007F 0-127 Basic Latin 0x0080-0x00FF 128-255 Latin-1 Suppl ...
- 微信emoji的code
const MAP = [ "\xc2\xa9" => 'COPYRIGHT SIGN', "\xc2\xae" => ...
- 字体jquery ---
You don’t need icons! Here are 100+ unicode symbols that you can use Danny Markov December 3rd, 2014 ...
- QQ表情代码大全,你知道几个??
很久没有给大家分享代码了,今天趁着有点时间来给大家分享一下QQ空间的表情代码!不用感谢我,大家拿去用吧! [em]e100[/em] 微笑bai[em]e101[/em] 撇嘴[em]e102[/em ...
- 【Star CCM+实例】开发一个简单的计算流程.md
流程开发在CAE过程中处于非常重要的地位. 主要的作用可能包括: 将一些经过验证的模型隐藏在流程中,提高仿真的可靠性 将流程封装成更友好的界面,降低软件的学习周期 流程开发实际上需要做非常多的工作,尤 ...
- github中的watch、star、fork的作用
[转自:http://www.jianshu.com/p/6c366b53ea41] 在每个 github 项目的右上角,都有三个按钮,分别是 watch.star.fork,但是有些刚开始使用 gi ...
- [deviceone开发]-Star分享的几个示例
一.简介 这个是star早期分享的几个示例,都非常实用,包括弹出的菜单,模拟支付密码输入等.初学者推荐.也可以直接使用.二.效果图 三.相关下载 https://github.com/do-proje ...
- 时隔一年再读到the star
The Star Arthur C. Clarke It is three thousand light-years to the Vatican. Once, I believed that spa ...
- Github上的Watch和 Star的区别
Github 推出了新的 Notification 系统,更改了原有的 Watch 机制,为代码库增加了 Star 操作.Notification 将接收 Watching 代码库的动态,包括:* I ...
随机推荐
- TCP/IP协议族各层的作用
从协议分层模型方面来讲,TCP/IP由四个层次组成:数据链路层.网络层.传输层.应用层一.数据链路层 数据链路层是负责接收IP数据报并通过网络发送之,或者从网络上接收物理帧,抽出IP数据报,交给IP层 ...
- bzoj 4310: 跳蚤
Description 很久很久以前,森林里住着一群跳蚤.一天,跳蚤国王得到了一个神秘的字符串,它想进行研究. 首先,他会把串分成不超过 k 个子串,然后对于每个子串 S,他会从S的所有子串中选择字典 ...
- 1.Nginx服务应用
Nginx服务应用 Nginx的优点和作用 Nginx是一款高性能的HTTP和反向代理的服务器软件,还是一个IMAP/POP3/SMTP(邮件)代理服务器! Nginx在功能实现上都采用模块化结构设计 ...
- Java NIO (二) 缓冲区(Buffer)
缓冲区(Buffer):一个用于特定基本数据类型的容器,由 java.nio 包定义的,所有缓冲区都是 Buffer 抽象类的子类. Java NIO 中的Buffer 主要用于和NIO中的通道(Ch ...
- 从源码(编译)安装golang 二
h1 { margin-top: 0.6cm; margin-bottom: 0.58cm; direction: ltr; color: #000000; line-height: 200%; te ...
- centos 命令
1.查看占用端口的进程 netstat -lnp|grep 3000(3000为端口号) Netstat 命令用于显示各种网络相关信息,如网络连接,路由表,接口状态 (Interface Statis ...
- javascript计算对象的长度
计算对象的长度,即获取对象属性的个数 方法一:通过for in 遍历对象,并通过hasOwnProperty判断是否是对象自身可枚举的属性 var obj = {"c1":1,&q ...
- Django ORM详解
ORM:(在django中,根据代码中的类自动生成数据库的表也叫--code first) ORM:Object Relational Mapping(关系对象映射) 我们写的类表示数据库中的表 我们 ...
- NET控件Designer架构设计
总体结构 Designer总体上由三大部分组成:View,ViewModel和Model,这个结构借鉴了流行的MVVM模式.这三部分的职责分工是: View 负责把ViewModel以图形的方式展现出 ...
- vuex 基本用法、兄弟组件通信,参数传递
vuex主要是是做数据交互,父子组件传值可以很容易办到,但是兄弟组件间传值,需要先将值传给父组件,再传给子组件,异常麻烦. vuex大概思路:a=new Vue(),发射数据'msg':a.$emit ...
