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. 关于llvm kaleidoscope: 记一次Debug血泪之路

    简而言之,慎(bu)用(yong)全局变量! 这次debug基本上花了我一周的时间,我基本上是晚上9点30下自习回然后调试到11点30,如此反复一周直到今天周五终于解决了,,以前都听说前辈们 说尽量不 ...

  2. deepin系统下部署Python3.5的开发及运行环境

    deepin系统下部署Python3.5的开发及运行环境 1 概述 由于最近要学习python接口自动化测试,所以记录一下相关学习经过及经验,希望对大家可以有所帮助. 2 下载 在python官网下载 ...

  3. JavaScript的DOM编程--11--插入节点

    插入节点: 1). insertBefore(): 把一个给定节点插入到一个给定元素节点的给定子节点的前面 var reference = element.insertBefore(newNode,t ...

  4. Python 阿里大于发送手机验证码

    1.安装阿里大于的包 pip install top 2.事例脚本 # -*- coding: utf-8 -*- import top.api appkey = '2353xxxx' secret ...

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

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

  6. Head First设计模式之解释器模式

    一.定义 给定一个语言,定义它的文法表示,并定义一个解释器,这个解释器使用该标识来解释语言中的句子. 主要解决:对于一些固定文法构建一个解释句子的解释器. 何时使用:如果一种特定类型的问题发生的频率足 ...

  7. XCopy命令实现增量备份

    xcopy XCOPY是COPY的扩展,可以把指定的目录连文件和目录结构一并拷贝,但不能拷贝系统文件:使用时源盘符.源目标路径名.源文件名至少指定一个:选用/S时对源目录下及其子目录下的所有文件进行C ...

  8. Nginx集群之WCF大文件上传及下载(支持6G传输)

    目录 1       大概思路... 1 2       Nginx集群之WCF大文件上传及下载... 1 3       BasicHttpBinding相关配置解析... 2 4       编写 ...

  9. 安卓电量优化之WakeLock锁机制全面解析

    版权声明:本文出自汪磊的博客,转载请务必注明出处. 一.WakeLock概述 wakelock是一种锁的机制,只要有应用拿着这个锁,CPU就无法进入休眠状态,一直处于工作状态.比如,手机屏幕在屏幕关闭 ...

  10. c语言贪吃蛇详解4.食物的投放与蛇的变长

    c语言贪吃蛇详解4.食物的投放与蛇的变长 前几天的实验室培训课后作业我布置了贪吃蛇,今天有时间就来写一下题解.我将分几步来教大家写一个贪吃蛇小游戏.由于大家c语言未学完,这个教程只涉及数组和函数等知识 ...