HDU 5563 Clarke and five-pointed star
2015-11-29 22:59
274 查看
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
\le T \le 10)T(1≤T≤10),
the number of the test cases.
For each test case, 5 lines follow. Each line contains 2 real numbers x_i,
y_i(-10^9 \le x_i, y_i \le 10^9)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}10−4.
For each test case, print YesYes if
they can compose a five-pointed star. Otherwise, print NoNo.
(If 5 points are the same, print YesYes.
)
Sample Input
Sample Output
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
\le T \le 10)T(1≤T≤10),
the number of the test cases.
For each test case, 5 lines follow. Each line contains 2 real numbers x_i,
y_i(-10^9 \le x_i, y_i \le 10^9)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}10−4.
For each test case, print YesYes if
they can compose a five-pointed star. Otherwise, print NoNo.
(If 5 points are the same, print YesYes.
)
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 暴力判断一下#include<cmath> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long long LL; const int maxn = 100005; const int base = 1e9 + 7; const double eps = 1e-4; int T, cnt; double x[5], y[5], dis[5]; int main() { scanf("%d", &T); while (T--) { for (int i = 0; i < 5; i++) scanf("%lf%lf", &x[i], &y[i]); int flag = 0; for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) dis[j] = (x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]); sort(dis, dis + 5); if (dis[2] - dis[1] < eps&&dis[4] - dis[3] < eps) if (dis[3] / dis[2]>1.3 || dis[3] < eps) flag++; } if (flag == 5) printf("Yes\n"); else printf("No\n"); } return 0; }
相关文章推荐
- 数据结构--向量--二分查找
- C# winForm__Gmap.net
- PMD格式(头文件)
- uboot - 启动内核过程分析
- Linux-dd命令详解【转】
- 责任链模式实例
- codeforces 380A. Sereja and Prefixes(折半查找)
- Apache服务的主要目录和配置文件详解
- achartengine画出动态折线图
- Windows Data Types
- pAdPt_-7 Hello BaiduMap [配置百度地图移动版开发环境(Android Studio)]
- HDU15年新生赛 1005 ACM组队安排(DP+组合公式)
- php memcache环境搭建
- docker 中 NGINX+PHP+MYSQL+REDIS+Elasticsearch 环境搭建 (linux系统)
- c# 使用sharppcap实现 网络抓包
- HBase--DependentColumnFilter(参考例过滤器 )详解
- 第二个Sprint冲刺第七天
- LeetCode 9 : Palindrome Number (Java)
- 通过ssh验证配置git服务端
- 简单实现用户注册,登录的留言簿