参考: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. webform添加到webapi的支持

    1.添加引用 添加对 System.Net.Http , System.Net.Http.Formatting , System.Web.Http , System.Web.Http.Common , ...

  2. 每日构建【Daily Build Using CruiseControl.NET and MSBuild】(转载)

    在上一篇项目 管理实践教程二.源代码控制[Source Control Using VisualSVN Server and TortoiseSVN]中 我们已经讲解了如何使用TortoiseSVN和 ...

  3. motto5

    No matter what others say,I won't forsake my priciples.

  4. ftp的20 21端口和主动被动模式

    ftp只支持tcp连接,不支持udp连接. ftp使用两个端口: 21(控制端口, 命令端口) , 20(数据端口) 21端口:  用来控制用户验证, 连接的建立和关闭:open/close/bye ...

  5. 基于jquery的相册预览gallery

    众多有图片的产品,都要加个图片预览功能.然后市面上就出现了各种各样的相册,下面也提供一个基于jquery的相册. 源码:https://github.com/lilyH/gallery 版本: v0. ...

  6. 昂贵的聘礼(dijkstra)

    昂贵的聘礼 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 38549   Accepted: 11158 Descripti ...

  7. Parencodings(imitate)

    Parencodings Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 20679   Accepted: 12436 De ...

  8. 最新 DEDECMS SQL 注入 0day

    4月29日消息:国内安全研究团队“知道创宇”称截获到最新DEDECMS SQL注入0day,DEDECMS官网目前提供下载的最新版5.7也受影响,截止本告警发出时官方尚未给出补丁或解决方案,此漏洞利用 ...

  9. ios开发者到真机测试

    ios就是矫情, 没事搞那么多步奏, 搞得我都不会弄了, 不懈努力后还是弄好了, 总结一下, 避免新人走弯路. 苹果的脾气就是这样, 只能慢慢学了 1.  生成CSR (开发者证书认证请求) 打开钥匙 ...

  10. poj3259 bellman——ford Wormholes解绝负权问题

    Wormholes Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 35103   Accepted: 12805 Descr ...