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 ...
随机推荐
- oracle初级(续)
有志者.事竟成,破釜沉舟,百二秦关终属楚: 苦心人.天不负,卧薪尝胆,三千越甲可吞吴. oracle基本简单的用法,之前的笔记稍作整理一下,希望对各位有用,如有问题可在下方留言,所有SQL都是经过or ...
- 关于ubuntu下qt编译显示Cannot connect creator comm socket /tmp/qt_temp.xxx/stub-socket的解决办法
今天在ubuntu下安装了qtcreator,准备测试一下是否能用,果然一测试就出问题了,简单编写后F5编译在gnome-terminal中出现 Cannot connect creator comm ...
- JDBC 程序实例小练习
JDBC 程序实例问题 编程实现如下功能:在数据库中建立一个表,表名为student,其结构为学号.姓名.性别.年龄.英语.JavaSE程序设计.初级日语.总分,在表中输入多条记录. 学生的总分信息, ...
- geoserver发布地图服务WMTS
WMTS: 切片地图web服务(OpenGIS Web Map Tile Service) WMTS提供了一种采用预定义图块方法发布数字地图服务的标准化解决方案.WMTS弥补了WMS不能提供分块地图的 ...
- mysql创建新用户及新用户不能本地登陆的问题
最近在搭建hadoop集群,主节点上面安装的MySQL数据库,对着方面不熟悉,为hive.Ooize等服务统一使用的root账号和密码,为了安全一些库对于某些用户是不可见的,所以需要针对不同的服务设置 ...
- ArcGIS API for JavaScript 4.2学习笔记[10] 2D添加指北针widget、视图保存、视图padding(第二章完结)
这几个例子是第二章除了入门之外比较简单的几个,就做个合集,把最核心的代码(第二参数)和 引用放上来即可,不作多解释. 2D地图添加指北针widget 2D地图一般修正方向为正北方就需要这个widget ...
- ArcGIS API for JavaScript 4.2学习笔记[13] Layer的弹窗(PopupTemplate)
上一篇文章中讲到Popup是一个弹窗,是View对象的默认内置弹窗,并且在View对象构造时就顺便构造了. 那么这个PopupTemplate是什么呢? 后半截单词Template是"模板& ...
- Python数据分析工具
1.Numpy 安装:pip install numpy [root@kvm work]# cat numpy_test.py #!/usr/bin/env python #coding:utf-8 ...
- 基于Java Mail 进行发送(带附件和压缩附件)的邮件
刚进公司的training, 下面是要求: Self-study of Java Mail library: http://www.oracle.com/technetwork/java/javam ...
- Q:javax.comm 2.0 windows下Eclipse的配置
@转自http://blog.csdn.net/zhuanghe_xing/article/details/7523744处 要在Windows下,对计算机的串口或并口等进行编程,可以选择使用Java ...