hdoj--5563--Clarke and five-pointed star(简单几何)
Clarke and five-pointed star
Total Submission(s): 601 Accepted Submission(s): 322
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.
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.
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.
)
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
![]()
五角星是一个对称性极高的图形,每一个点连得线都与其他点的连线一毛一样,有木有很神奇(并没有),这道题只需要算出每一个点的所有连线,然后判断就好,水题一枚
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
struct node
{
double x,y;
}p[10010];
double dis1[10],dis2[10],dis3[10],dis4[10],dis5[10];
double d(node s1,node s2)
{
return sqrt((s1.x-s2.x)*(s1.x-s2.x)+(s1.y-s2.y)*(s1.y-s2.y));
}
int cmp(double a,double b)
{
if(a>b)
return 1;
return 0;
}
int er(double a,double b)
{
if(fabs(a-b)<1e-3)
return 1;
return 0;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int i,j;
for(i=0;i<5;i++)
scanf("%lf%lf",&p[i].x,&p[i].y);
for(j=0;j<5;j++)
dis1[j]=d(p[0],p[j]);
for(j=0;j<5;j++)
dis2[j]=d(p[1],p[j]);
for(j=0;j<5;j++)
dis3[j]=d(p[2],p[j]);
for(j=0;j<5;j++)
dis4[j]=d(p[3],p[j]);
for(j=0;j<5;j++)
dis5[j]=d(p[4],p[j]);
sort(dis1,dis1+5,cmp);
sort(dis2,dis2+5,cmp);
sort(dis3,dis3+5,cmp);
sort(dis4,dis4+5,cmp);
sort(dis5,dis5+5,cmp);
for(i=0;i<5;i++)
{
if(er(dis1[i],dis2[i])&&
er(dis2[i],dis3[i])&&
er(dis3[i],dis4[i])&&
er(dis4[i],dis5[i])&&
er(dis5[i],dis1[i]));
else break;
}
if(i==5)
printf("Yes\n");
else
printf("No\n");
}
return 0;
}
hdoj--5563--Clarke and five-pointed star(简单几何)的更多相关文章
- Python下opencv使用笔记(二)(简单几何图像绘制)
简单几何图像一般包含点.直线.矩阵.圆.椭圆.多边形等等.首先认识一下opencv对像素点的定义. 图像的一个像素点有1或者3个值.对灰度图像有一个灰度值,对彩色图像有3个值组成一个像素值.他们表现出 ...
- Codeforces 935 简单几何求圆心 DP快速幂求与逆元
A #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #def ...
- hdu 5563 Clarke and five-pointed star 水题
Clarke and five-pointed star Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/show ...
- HDOJ 1393 Weird Clock(明白题意就简单了)
Problem Description A weird clock marked from 0 to 59 has only a minute hand. It won't move until a ...
- HDOJ 1393 Weird Clock(明确题意就简单了)
Problem Description A weird clock marked from 0 to 59 has only a minute hand. It won't move until a ...
- HDOJ 1196 Lowest Bit(二进制相关的简单题)
Problem Description Given an positive integer A (1 <= A <= 100), output the lowest bit of A. F ...
- ACM: FZU 2110 Star - 数学几何 - 水题
FZU 2110 Star Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Pr ...
- 简单几何(线段相交) POJ 2653 Pick-up sticks
题目传送门 题意:就是小时候玩的一种游戏,问有多少线段盖在最上面 分析:简单线段相交,队列维护当前最上的线段 /******************************************** ...
- osg for android (一) 简单几何物体的加载与显示
1. 首先需要一个OSG for android的环境. (1).NDK 现在Eclipse 对NDK已经相当友好了,已经不需要另外cygwin的参与,具体可以参考 Android NDK开发篇(一) ...
随机推荐
- 从QQ聊天看交流的有效性
首先让我们看一则约10分钟的QQ群聊天记录.截图例如以下.已经进行了隐私保护. 交流的主体为大二的在校生与刚刚毕业的学长之间的对话,学长參加过培训,在校学弟想了解一下.故有了以下的交流.(从上到下,从 ...
- C++ STL 源代码学习(之deque篇)
stl_deque.h /** Class invariants: * For any nonsingular iterator i: * i.node is the address of an el ...
- Android recycleView的研究和探讨
RecyclerViewLibrary A RecyclerView libirary ,has some support, like headerAdapter/TreeAdapter,and Pu ...
- mybatis学习笔记(7)-输出映射
mybatis学习笔记(7)-输出映射 标签: mybatis mybatis学习笔记7-输出映射 resultType 输出简单类型 输出pojo对象和pojo列表 resultMap result ...
- jdbc14 及 jdbc16 共存所带来的问题【未完待续】
在JAVA中JDK版本号与JDBC版本号的一致性十分重要,开发都们经常会忽略了这一点导致非常多不必要的错误. 昨天给客户排查了一个关于EDB在JBoss中使用时关于这方面的问题,希望给大家一点启示. ...
- httpClient模拟登陆校内某系统
package com.huowolf; import java.util.ArrayList; import java.util.List; import org.apache.http.HttpE ...
- bzoj3993: [SDOI2015]星际战争(网络流)
3993: [SDOI2015]星际战争 题目:传送门 题解: 洛谷AC了,但是因为bzoj的spj有问题所以暂时没A 一道老题目了,二分时间然后网络流判断. 每次st-->武器连时间*攻击力 ...
- springMVC接受参数总结
springMVC接受参数分类及使用对应注解才能正确接受到参数,否则报400或者接受的参数值为null: 1.接受单个参数 @RequestParam 不需要转json串 2.接受一个实体 @Requ ...
- Django(part4)
一个简单的form表单: #polls/templates/polls/detail.html<h1>{{ question.question_text }}</h1> {% ...
- XManager远程Linux 安装Oracle 图形化界面xstart解决方法
一.安装Oracle_11g_R21.安装所必要的软件包:(CentOS)参见官方文档-rw-r--r--. 1 oracle oinstall 1358454646 Feb 5 22:57 p10 ...
