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. iOS 让图片变模糊

    #import <Accelerate/Accelerate.h> 1.初始化图片 UIImageView *iv = [[UIImageView alloc]initWithFrame: ...

  2. ftp 只需上传禁止下载

    一.首先在ftp / 主目录下给所有用户授予读写权限 二.给子目录授予写入权限,不允许读取

  3. Python下载一张图片与有道词典

    1.下载一张图片代码1 import urllib.request response = urllib.request.urlopen('http://photocdn.sohu.com/201009 ...

  4. 利用generator自动生成model(实体)、dao(接口)、mapper(映射)

    1 在MySQL数据库中创建相应的表 /* Navicat MySQL Data Transfer Source Server : 虚拟机_zeus01 Source Server Version : ...

  5. BOOTPROTO=[none|static|bootp|dhcp](引导时不使用协议|静态分配|BOOTP协议|DHCP协议)

     BOOTPROTO=[none|static|bootp|dhcp](引导时不使用协议|静态分配|BOOTP协议|DHCP协议) 

  6. SSIS 实用表达式部分总结

    下面,列出一些实用的表达式: 1,路径取文件名 RIGHT([FilePath],FINDSTRING(REVERSE([FilePath]),) - ) RIGHT(@[User::FilePath ...

  7. Mac_OS_Sierra_10.12.6编译OpenJDK9

    编译环境以及依赖 macOS:Sierra,10.12.6 处理器:2.6 GHz Intel Core i7 内存:16 GB 2133 MHz LPDDR3 Command Line Tools ...

  8. python2 与python3的变化

    1 写文件如果是bytes类型的话,打开文件 open参数设置为wb 2 python2 默认包import是相对路径,python3是绝对路径 3 python3的dict没有has_key方法,用 ...

  9. 设置状态栏(UIStatusBar)样式

    方法1:找到项目里面的info.plist文件,添加属性Status bar style,设置属性值为transparent black style 状态条为白色 ,设置属性值为 gray style ...

  10. Vue 爬坑之路(九)—— 用正确的姿势封装组件

    迄今为止做的最大的 Vue 项目终于提交测试,天天加班的日子终于告一段落... 在开发过程中,结合 Vue 组件化的特性,开发通用组件是很基础且重要的工作 通用组件必须具备高性能.低耦合的特性 为了满 ...