参考:http://blog.csdn.net/libin56842/article/details/26618129

题意:给一个正多边形内点到其他顶点的距离(逆时针给出),求正多边形的边长

二分多边形的边长

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAYQAAAF1CAIAAABnEQo4AAAUaUlEQVR4nO2Z23UcSQ5EaZcMoj2yRs7ImN6PnsOl2F1VWZl4BJD3fs6ShUAEMrSa+XgAAAjwkS0AAODxoIwAQATKCAAkoIwAQALKCAAkoIwAQALKCAAkoIwAQALKCAAkoIwAQALKCAAkoIwAQALKCAAkoIwAQALKCAAkoIwAQALKCAAkoIwAQALKCAAkoIwAQALKCAAkoIwAQALKCAAkoIwAQALKCAAkoIwAQALKCAAkoIwAQALKCAAkoIwAQALKCAAkoIwAQALKCAAkoIwAQALKCAAkoIwAQALKCAAkoIwAQALKCAAkoIwAQALKCAAkoIwAQALKCAAkoIwAQALKCC74WCZ7A6gBhwKPh0XjUFKwCAexHSm9M0i2N5AJ8fcnu2GWyDYP4iDsnmR3iAvZpoIvBNyHmPfv8SsmwqA6hFqeyLed8jWTWaAPWVYl/vUGTJleamUvEIEIi5HyULMKImUoZEFyNUh8kyffV5ARMBpiIDB1cp/f+SA1VTHTwQmiEiX9sY1MVCiFdAFgBQnJofC6xie+/YGUOkg3DRYhGyFEntOtuUc/oyY+WAZMQCoSiLyfieknP5ZbBCOWhomBEQgjGZ0HMz39/OfTW0DHYTiHGHJQeyErGi5/RXlBKkkHAohG8FUsyhj5LfFNqSQFsD4UtZdgImPw1/W3po9ywfcgBB+AoZLxL+ivTyVlgePuaB69rZhbHynhA5UUD177InjoHnrufkfKkBM99FEkGO2F5n376Zn4YBVzqKQYsNge2Zt2lTT3zUIupQtrD+YaI3vH3qqmP1vLrnRhjcFZM07ON/eCYyStfLyWb+nCuoKnNshebaSqxRG1DEwX1g8MNUD2WIOFrU/ByZ3BzSVk/9hMUWUyS9PPE2EK2nqAj/PInmaWMMOJeLshmDiJ7FHmCjMcisO7gYO3ObrF9HNUEGY7N32du8I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NPsjw4OE/kGwAFTkLPPsYOYOIS54cLnSBrb/DRAG60PUQcAG7awB+bXSHZMDDUjJOr5XArQqDB4KkxnG8PyDEenLWHP1FLQ3xZYK4X3HQ5iCwXLPaF+64CMaWD0e6c9xG3ng7piIDXQVBJapCIGjgeCg9AgcsUCCIFTI+Gl5AI5iuD9TnwKoLBcH0IIBNeSACYXAViyGfktfBg7oKr5SAMIXg/6wx6iI2CEIkcvKU5qKHqEIwoPK1BMKoNJCTN+Evb6r1hS0vIqQZ3n1+/F4gD7SGwYuz2Jnfbd2dIrioTr7TEW53eS381OIf8arPydNOfcWnxYA5B9sHqbds+dU1VIAih9sSpAnLJNhV8IeD+ZHfIEtnmQRyEvR3Z9XJBtj2QBtnD45HUUNlLgxYcBFxD40AA3AoASEAZAYAElBEASEAZAYAElBEASEAZAYAElBEASEAZAYAElBEASEAZAYAElBEASEAZAYAElBEASEAZAYAElBEASEAZAYAElBEASEAZAYAElBEASEAZAYAElBEASEAZAYAElBEASEAZAYAElBEASEAZAYAElBEASEAZAYAElBEASEAZAYAElBEASEAZAYAElBEASEAZAYAElBEASEAZAYAElBEASPA/+iI+eg+jlXoAAAAASUVORK5CYII=" alt="" />

根据余弦定理求出A的角度,之后求出所有角度,加起来是否为360,小于则扩大,大于则缩小边

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
 #include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std;
#define pi acos(-1.0)
#define exp 1e-8
int main()
{
int t,n,i,j,flag,cas = ;
double a[];
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
flag = ;
for(i = ; i<n; i++)
scanf("%lf",&a[i]);
a[n] = a[];
double l = ,r = ,mid;
for(i = ; i<=n; i++)
{
r = min(r,a[i]+a[i-]);
l = max(l,fabs(a[i]-a[i-]));
}
while(r-l>exp)
{
mid = (l+r)/;
double s,sum=;
for(i = ; i<=n; i++)
{
s = (a[i]*a[i]+a[i-]*a[i-]-mid*mid)/(2.0*a[i]*a[i-]);
sum+=acos(s);
}
if(fabs(sum-*pi)<exp)
{
flag = ;
break;
}
else if(sum>*pi)
r = mid;
else
l = mid;
}
printf("Case %d: ",cas++);
if(flag)
printf("%.3f\n",mid);
else
printf("impossible\n");
} return ;
}

hdu 4033 二分几何的更多相关文章

  1. hdu 4024 二分

    转自:http://www.cnblogs.com/kuangbin/archive/2012/08/23/2653003.html   一种是直接根据公式计算的,另外一种是二分算出来的.两种方法速度 ...

  2. hdu 4033 2011成都赛区网络赛 余弦定理+二分 **

    二分边长,判断最后内角和是否为2pi,注意l与r的选取,保证能组成三角形 #include<cstdio> #include<iostream> #include<alg ...

  3. hdu 4033 Regular Polygon 计算几何 二分+余弦定理

    题目链接 给一个n个顶点的正多边形, 给出多边形内部一个点到n个顶点的距离, 让你求出这个多边形的边长. 二分边长, 然后用余弦定理求出给出的相邻的两个边之间的夹角, 看所有的加起来是不是2Pi. # ...

  4. hdu 1669(二分+多重匹配)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1669 思路:由于要求minimize the size of the largest group,由此 ...

  5. HDU 3586 二分答案+树形DP判定

    HDU 3586 『Link』HDU 3586 『Type』二分答案+树形DP判定 ✡Problem: 给定n个敌方据点,1为司令部,其他点各有一条边相连构成一棵树,每条边都有一个权值cost表示破坏 ...

  6. hdu 4004 (二分加贪心) 青蛙过河

    题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4004 题目意思是青蛙要过河,现在给你河的宽度,河中石头的个数(青蛙要从石头上跳过河,这些石头都是在垂 ...

  7. hdu 5046 二分+DLX模板

    http://acm.hdu.edu.cn/showproblem.php?pid=5046 n城市建k机场使得,是每个城市最近机场的距离的最大值最小化 二分+DLX 模板题 #include < ...

  8. HDU 5699 二分+线性约束

    http://acm.hdu.edu.cn/showproblem.php?pid=5699 此题满足二分性质,关键在于如何判断当前的时间值可以满足所有的运送方案中的最长的时间. 对于每一次枚举出的k ...

  9. hdu 3277(二分+最大流+拆点+离线处理+模板问题...)

    Marriage Match III Time Limit: 10000/4000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

随机推荐

  1. (转)CSS3 @font-face

    @font-face是CSS3中的一个模块,他主要是把自己定义的Web字体嵌入到你的网页中,随着@font-face模块的出现,我们在Web的开发中使用字体不怕只能使用Web安全字体,你们当中或许有许 ...

  2. Swift定义单例

    而在Swift中我们通过清晰的语法便能定义类变量: 通过static定义的类变量无法在子类重写,通过class定义的类变量则可在子类重写. struct SomeStructure { static ...

  3. Zabbix 监控 Nginx 状态

    简介: 如何使用 Zabbix 监控 Nginx 状态 ? 1.获取 Nginx 状态( HTTP Stub Status ) shell > /usr/local/nginx/sbin/ngi ...

  4. mysql 自连接

    SELECT语句中的自连接. 到目前为止,我们连接的都是两张不同的表,那么能不能对一张表进行自我连接呢?答案是肯定的. 有没有必要对一张表进行自我连接呢?答案也是肯定的. 表的别名: 一张表可以自我连 ...

  5. 宿主机为linux、windows分别实现VMware三种方式上网(转)

    一.VMware三种方式工作原理1 Host-only连接方式  让虚机具有与宿主机不同的各自独立IP地址,但与宿主机位于不同网段,同时为宿主主机新增一个IP地址,且保证该IP地址与各虚机IP地址位于 ...

  6. 基于.NET的大型Web站点StackOverflow架构分析(转)

    Stack Overflow网址:http://stackoverflow.com/ 当前访问量:每月9500PV(每天300多万PV) 当前Alexa排名:149 所用.NET技术:C#.Visua ...

  7. C# 三种实现抖屏的方式

    //int a = -2; //this.BringToFront(); //for (int i = 0; i < 20; i++) //{ // a = -a; // this.Locati ...

  8. jQuery1.11源码分析(9)-----初始化jQuery对象的函数和关联节点获取函数

    这篇也没什么好说的,初始化jQuery对象的函数要处理多种情况,已经被寒冬吐槽烂了.关联节点获取函数主要基于两个工具函数dir和sibling,前者基于指定的方向遍历,后者则遍历兄弟节点(真的不能合并 ...

  9. 最近打算体验一下discuz,有不错的结构化数据插件

    提交sitemap是每位站长必做的事情,但是提交到哪里,能不能提交又是另外一回事.国内的话百度是大伙都会盯的蛋糕,BD站长工具也会去注册的,可有些账号sitemap模块一直不能用,或许是等级不够,就像 ...

  10. Linux下的网络管理工具—OpenNMS

    导读 OpenNMS的是一个运营商级别的,高度集成的,开放源码的平台,用于构建网络监控解决方案.OpenNMS有两个发行版:Meridian and Horizon.使用Meridian是可取的,对企 ...