Regular Polygon
Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65768/65768 K (Java/Others)
Total Submission(s): 1041Accepted Submission(s): 295
Problem Description
In a 2_D plane, there is a point strictly in a regular polygon with N sides. If you are given the distances between it and N vertexes of the regular polygon, can you calculate the length of reguler polygon's side? The distance is
defined as dist(A, B) = sqrt( (Ax-Bx)*(Ax-Bx) + (Ay-By)*(Ay-By) ). And the distances are given counterclockwise.
Input
First a integer T (T≤ 50), indicates the number of test cases. Every test case begins with a integer N (3 ≤ N ≤ 100), which is the number of regular polygon's sides. In the second line are N float numbers, indicate the distance between
the point and N vertexes of the regular polygon. All the distances are between (0, 10000), not inclusive.
Output
For the ith case, output one line “Case k: ” at first. Then for every test case, if there is such a regular polygon exist, output the side's length rounded to three digits after the decimal point, otherwise output “impossible”.
Sample Input
2
3
3.0 4.0 5.0
3
1.0 2.0 3.0
Sample Output
Case 1: 6.766
Case 2: impossible
Source
可以直接二分那个边长,然后通过计算内角和是否大于360来判断当前的边长是否合理
我的代码:
分享到:
相关推荐
收集的部分HDOJ杭电ACM题的代码 大牛勿下 全是基础供初级acmer使用
ACM ICPC HDOJ1000
自己积累的部分杭电oj的(hdu)解题代码。。大家有空来看看。 基本上是自己写的哈。有错误之处请指教、
HDOJ,2011阿里巴巴程序设计公开赛的标程 题目位置:http://acm.hdu.edu.cn/vip/2011alibaba/index.php
杭电acm解题报告 详细解析2000-2099 适合acm初学者
HDOJ题目分类HDOJ题目分类HDOJ题目分类
杭电 OJ Java版的,考虑到大多数都是c++版的,或许Java版的会对你有所帮助。
ACM ICPC HDOJ1002
ACM ICPC HDOJ1001
hdoj1001标程
hdoj上的资源,代码有注释,很不错的哦
杭州电子科技大学hdoj1002,大整数相加问题
codj,hdoj的源码(50-60题)
hdoj1004,解题代码,答案代码,欢迎下载
杭电oj4405,一道简单的概率dp题目
ACM ICPC HDOJ1008
c语言 最短路 是hdoj上的一个最短路问题,写的很牛
ACM ICPC HDOJ1003
杭州电子科大HDOJ
hdoj解题代码,题目为1000-1050