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开发篇(一) ...
随机推荐
- gdb学习-checkpoint,watch
checkpoint的内容参考: http://blog.chinaunix.net/uid-23629988-id-2943273.html 这一篇主要是checkpoint,在next之前加che ...
- [CSS3] CSS Background Images
Body with background image and gradient html { background: linear-gradient(#000, white) no-repeat; h ...
- 怎样用批处理来执行多个exe文件
怎样用批处理来运行多个exe文件 @echo off start *****.exe start *****.exe start *****.exe start *****.exe 接着我们就能够运行 ...
- 微软柯塔娜(Cortana)的一句名言
近日.媒体频传Win 10装机量已经超过多少千万台.我操心的问题是,集成在Win 10操作系统中的柯塔娜小姐将怎样面对各色各样的人群.由于,在这个世界上.人是最复杂的生物,什么人都有. 依据国外媒体报 ...
- 模仿百度首页“元宵节汤圆”动图(js的定时任务:setInterval)
模仿百度首页“元宵节汤圆”动图:(js的定时任务:setInterval) 原理:需要一张切图,通过不断定位使得图片就像一帧一帧的图片在播放从而形成了动画 效果图: 切图地址: https://ss1 ...
- SqlDependency C#代码监听数据库表的变化
SqlDependency提供了这样一种能力:当被监测的数据库中的数据发生变化时,SqlDependency会自动触发OnChange事件来通知应用程序,从而达到让系统自动更新数据(或缓存)的目的. ...
- python 3.x 学习笔记15(多线程)
1.线程进程进程:程序并不能单独运行,只有将程序装载到内存中,系统为它分配资源才能运行,而这种执行的程序就称之为进程,不具备执行感念,只是程序各种资源集合 线程:线程是操作系统能够进行运算调度的最小单 ...
- Gram矩阵 迁移学习 one-shot 之类
格拉姆矩阵是由内积空间中的向量两两内积而得.格拉姆矩阵在向量为随机的情况下也是协方差矩阵.每个数字都来自于一个特定滤波器在特定位置的卷积,因此每个数字代表一个特征的强度,而Gram计算的实际上是两两特 ...
- Ubuntu系统下安装Eclipse
第一步:查看操作系统位数. 打开终端,输入file /sbin/init 可以看到笔者Ubuntu系统为32位,读者可以使用该命令获取自己机器上的操作系统位数. 这一步是最至关重要的一步,笔者机器处理 ...
- 1806最大数 string和sort函数用法
1.C++自带sort函数用法 sort函数有三个参数: (1)第一个是要排序的数组的起始地址 (2)第二个是结束的地址(最后一位要排序的地址) (3)第三个参数是排序的方法,可以是从大到小也可是从小 ...
