设为首页 加入收藏

TOP

poj 1905 (二分查找)
2015-07-20 17:22:48 来源: 作者: 【 】 浏览:2
Tags:poj 1905 二分 查找

链接:poj 1905

?

截取自某大牛的blog,详情请关注:链接:Enumz

?

题意:一根两端固定在两面墙上的杆长度为L,受热弯曲后变弯曲,

长度L′=(1+nc)*L,求前后两个状态的杆的中点位置的距离

?

分析:设L′对应的半径为r,弧长为2α,要求的距离为x

?

根据直角三角形的性质可得:

\

根据弧长公式L′=2αr可得

\


有勾股定理得出:

\

代入得:

\

其为单调函数,二分求解即可。
PS:卡精度 特判若输入存在0,则直接输出0.000

?

?

#include
  
   
#include
   
     #define eps 1e-6 double l,s; double bin_search(double low,double high) { double mid; while(high-low>eps){ mid=(low+high)/2; double temp=(l*l/4+mid*mid)/mid*asin(mid*l/(l*l/4+mid*mid)); if(temp>s) high=mid; else low=mid; } return mid; } int main() { double c,n; while(scanf("%lf%lf%lf",&l,&n,&c)!=EOF){ if(l==-1&&n==-1&&c==-1) break; if(l==0||n==0||c==0){ printf("0.000\n"); continue; } s=(1+n*c)*l; double ansH=bin_search(0.0,l/2); printf("%.3lf\n",ansH); } return 0; }
   
  

?

?

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇BZOJ 3198 Sdoi2013 spring Hash+.. 下一篇easyui中combotree循环获取父节点..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·MySQL 基础入门视频 (2025-12-26 23:20:22)
·小白入门:MySQL超详 (2025-12-26 23:20:19)
·关于 MySQL 数据库学 (2025-12-26 23:20:16)
·SOLVED: Ubuntu 24.0 (2025-12-26 22:51:53)
·Linux 常用命令最全 (2025-12-26 22:51:50)