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

Problem 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

/*
*题目大意:给你五个点的坐标、要求判断是否可以组成五角星
*算法分析:注意在五点相同时候为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的更多相关文章

  1. all unicode

    Unicode Chart Range Decimal Name 0x0000-0x007F 0-127 Basic Latin 0x0080-0x00FF 128-255 Latin-1 Suppl ...

  2. 微信emoji的code

    const MAP = [        "\xc2\xa9" => 'COPYRIGHT SIGN',        "\xc2\xae" => ...

  3. 字体jquery ---

    You don’t need icons! Here are 100+ unicode symbols that you can use Danny Markov December 3rd, 2014 ...

  4. QQ表情代码大全,你知道几个??

    很久没有给大家分享代码了,今天趁着有点时间来给大家分享一下QQ空间的表情代码!不用感谢我,大家拿去用吧! [em]e100[/em] 微笑bai[em]e101[/em] 撇嘴[em]e102[/em ...

  5. 【Star CCM+实例】开发一个简单的计算流程.md

    流程开发在CAE过程中处于非常重要的地位. 主要的作用可能包括: 将一些经过验证的模型隐藏在流程中,提高仿真的可靠性 将流程封装成更友好的界面,降低软件的学习周期 流程开发实际上需要做非常多的工作,尤 ...

  6. github中的watch、star、fork的作用

    [转自:http://www.jianshu.com/p/6c366b53ea41] 在每个 github 项目的右上角,都有三个按钮,分别是 watch.star.fork,但是有些刚开始使用 gi ...

  7. [deviceone开发]-Star分享的几个示例

    一.简介 这个是star早期分享的几个示例,都非常实用,包括弹出的菜单,模拟支付密码输入等.初学者推荐.也可以直接使用.二.效果图 三.相关下载 https://github.com/do-proje ...

  8. 时隔一年再读到the star

    The Star Arthur C. Clarke It is three thousand light-years to the Vatican. Once, I believed that spa ...

  9. Github上的Watch和 Star的区别

    Github 推出了新的 Notification 系统,更改了原有的 Watch 机制,为代码库增加了 Star 操作.Notification 将接收 Watching 代码库的动态,包括:* I ...

随机推荐

  1. php面向对象4

    成员属性 基本介绍 成员属性是类的一个组成部分,一般是基本数据类型,也可以是复合类型,资源类型.比如 public $age;就是成员属性 说明 ①成员属性可以是php的任何数据类型(int, flo ...

  2. 模板引擎(smarty)知识点总结II

    今天咱们继续来学习smarty!!! 知识点1:对于三种变量 常量的引用 有哪三种变量?a.assign赋值 b.系统保留变量(包括:$smarty.get,$smarty.post,$smarty. ...

  3. docker 保存 加载(导入 导出镜像

    tensorflow 的docker镜像很大,pull一次由于墙经常失败.其实docker 可以将镜像导出再导入. 保存加载(tensorflow)镜像 1) 查看镜像 docker images 如 ...

  4. thinkphp 3.1.3 redis 只能读取 无法写入的问题

    找到thinkphp的目录 thinkphp\Extend\Driver\Cache    下面的Redis    大概在81行足有 // if(is_int($expire)) { // redis ...

  5. 怎么制作html5网站页面让它适应电脑和手机的尺寸

    https://zhidao.baidu.com/question/918130826792192539.html 用以下代码开头:<!DOCTYPE HTML><html>& ...

  6. 关于recycleview 滑动item变长(item变形)问题

    昨天在做项目的时候出现了bug,表现是在滑动的时候,整个item会被拉长了,松手后就回归正常大小了, 出现这个的主要原因是因为你的item布局中最大的那个根布局是 match_parent状态,因此导 ...

  7. Lucene.net(4.8.0) 学习问题记录三: 索引的创建 IndexWriter 和索引速度的优化

    前言:目前自己在做使用Lucene.net和PanGu分词实现全文检索的工作,不过自己是把别人做好的项目进行迁移.因为项目整体要迁移到ASP.NET Core 2.0版本,而Lucene使用的版本是3 ...

  8. 自动刷新 CSS文件

    自动刷新 CSS文件 使用任何代码工具码 CSS,都是需要保存后再切换到浏览器按 F5 刷新查看效果,一次又一次,不管这个改动仅是一个小小的颜色.使用 CSSrefresh 后,改动 CSS 文件保存 ...

  9. 极光配置-》thinkphp3.2.3

    1,小白我搞了几天,终于得到了这样的结果(我猜应该是成功了吧). { "body": { "sendno": "100000", " ...

  10. Python打印:九九乘法表

    代码: i = 1 while i <= 9: n = 1 while n <=i: print("%d*%d=%d\t"%(n,i,i*n),end="&q ...