一根细棒升温时会变长,在两面墙中间,会变成一个弓形。

给出变长后的长度,求新的细棒中心与没伸长时的中心的距离。

简单的数学推导后就可以二分答案了,一开始没完全掌握二分的姿势,wa了好多。而且poj double输出要用%f,用%lf就wa了。

#include <cstdio>
#include <cmath>
#include <algorithm> using namespace std; const double eps = 1e-;
double n,c,L; double func(double x)
{
//if(fabs(x-0) < eps) return ;
double r = (x*x+L*L/4.0)/(*x);
return *r*asin(L/(2.0*r));
} int main()
{
while(scanf("%lf%lf%lf",&L,&n,&c))
{
if(L< && n< && c<)
break; double low = 0.0,high = 0.5*L;
double mid = (low+high)/2.0;
double s = (+n*c)*L;
double ans = ; while(high-low>eps)
{
//printf("%lf %lf %lf\n",low,mid,high);
//printf("%lf %lf %lf\n",func(low),func(mid),func(high)); if(func(mid) < s)
low = mid;
else
high = mid; mid = (low+high)/2.0;
}
//printf("%f %f\n",mid,L);
printf("%.3f\n",mid);
}
}

POJ1905-Expanding Rods-二分答案的更多相关文章

  1. POJ 1905 Expanding Rods 二分答案几何

    题目:http://poj.org/problem?id=1905 恶心死了,POJ的输出一会要lf,一会要f,而且精度1e-13才过,1e-12都不行,错了一万遍终于对了. #include < ...

  2. Expanding Rods(二分POJ1905)

    Expanding Rods Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 13688   Accepted: 3527 D ...

  3. poj1905 Expanding Rods(二分)

    题目链接:https://vjudge.net/problem/POJ-1905 题意:有一根长len的木棍,加热了n度,长度会膨胀为len*(1+n*c),c为膨胀系数.现在把这根木棍夹在两堵墙之间 ...

  4. 二分法 (UVA10668 Expanding Rods)(二分+几何)

    转载请注明出处:優YoU http://user.qzone.qq.com/289065406/blog/1301845324 大致题意: 一根两端固定在两面墙上的杆 受热弯曲后变弯曲.求前后两个状态 ...

  5. Expanding Rods(二分)

    Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 10287   Accepted: 2615 Description When ...

  6. poj 1905 Expanding Rods 二分

    /** 题解晚上写 **/ #include <iostream> #include <math.h> #include <algorithm> #include ...

  7. 【二分答案】Expanding Rods POJ 1905

    题目链接:http://poj.org/problem?id=1905 题目大意:原长度为L的线段因受热膨胀为一段弧,线段L.弧长L'.温度n.膨胀率c满足L' =(1+n/c)*L;求线段的中点移动 ...

  8. UVA 10668 - Expanding Rods(数学+二分)

    UVA 10668 - Expanding Rods 题目链接 题意:给定一个铁棒,如图中加热会变成一段圆弧,长度为L′=(1+nc)l,问这时和原来位置的高度之差 思路:画一下图能够非常easy推出 ...

  9. D - Expanding Rods POJ - 1905(二分)

    D - Expanding Rods POJ - 1905 When a thin rod of length L is heated n degrees, it expands to a new l ...

  10. POJ 1905:Expanding Rods 求函数的二分

    Expanding Rods Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 13780   Accepted: 3563 D ...

随机推荐

  1. 使用 WebSocket 客户端连接 MQTT 服务器

    简介 近年来随着 Web 前端的快速发展,浏览器新特性层出不穷,越来越多的应用可以在浏览器端或通过浏览器渲染引擎实现,Web 应用的即时通信方式 WebSocket 得到了广泛的应用. WebSock ...

  2. 理解maven中SNAPSHOT版本的作用

    https://leokongwq.github.io/2017/08/24/understanding-maven-snapshot.html 一次针对现有的http服务开发了一个SNAPSHOT版 ...

  3. 实现Cookie集合

    以前Insus.NET有在博客上有写过一篇<在程序中使用Cookie集合>http://www.cnblogs.com/insus/archive/2011/05/25/2055531.h ...

  4. Python 学习 第七篇:函数1(定义、调用和变量的作用域)

    函数是把一些语句集合在一起的程序结构,用于把复杂的流程细分成不同的组件,能够减少代码的冗余.代码的复用和修改代码的代价. 函数可以0个.1个或多个参数,向函数传递参数,可以控制函数的流程.函数还可以返 ...

  5. js类型----你所不知道的JavaScript系列(5)

    ECMAScirpt 变量有两种不同的数据类型:基本类型,引用类型.也有其他的叫法,比如原始类型和对象类型等. 1.内置类型 JavaScript 有七种内置类型: • 空值(null) • 未定义( ...

  6. java垃圾回收诡异现象

    在知乎上看到一篇提问,于是做了个实验帮助他解答,这里整理成一篇文章分享一下. 先看代码如下代码: /** * Created on 2017/12/16. * * -verbose:gc -XX:+U ...

  7. ssh登陆服务器locale告警(-bash: warning: setlocale:)的处理方法

    使用ssh远程登陆 IDC机房服务器,发现老是出现如下告警信息: -bash: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UT ...

  8. hive基础操作—(1)

    执行./hive命令后,进入CLI(shell)模式: 1.创建数据库,语句: create database school; 2.展示所有的数据库,语句: show databases; 3.选择使 ...

  9. omnigraffle 的一些总结

    http://jingyan.baidu.com/article/fcb5aff7a16337edab4a714d.html Omnigraffle绘制连接线时从任意点开始 点击直线工具后,在右侧设置 ...

  10. PHP输入流 php://input 相关【转】

    为什么xml_rpc服务端读取数据都是通过file_get_contents(‘php://input', ‘r').而不是从$_POST中读取,正是因为xml_rpc数据规格是xml,它的Conte ...