题目链接:https://vjudge.net/problem/POJ-1905

题意:有一根长len的木棍,加热了n度,长度会膨胀为len*(1+n*c),c为膨胀系数。现在把这根木棍夹在两堵墙之间,木棍会向上弯曲变成弧形,求弧形中点和原木棍中点的高度差。

思路:刚开始以为是几何题,几何肯定是能做的。然后发现题解是二分,第一次二分double类的变量,学到了。设所求答案为dis,通过dis可以勾骨出半径R,然后求出弧长L,再比较L与真实弧长len。显然dis和L满足二分的单调性,那么就可以做了。

AC代码:

#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std; double len,len1,n,c;
const double eps=1e-; bool check(double d){
double R=d/+len*len//d;
return *R*acos((R-d)/R)<=len1;
} int main(){
while(scanf("%lf%lf%lf",&len,&n,&c),len>=){
if(len<eps||n<eps||c<eps){
printf("0.000\n");
continue;
}
len1=(1.0+n*c)*len;
double l=1e-,r=len/,mid;
while(l<=r){
mid=(l+r)/;
if(check(mid)) l=mid+(1e-);
else r=mid-(1e-);
}
printf("%.3f\n",r);
}
return ;
}

poj1905 Expanding Rods(二分)的更多相关文章

  1. Expanding Rods(二分POJ1905)

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

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

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

  3. Expanding Rods(二分)

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

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

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

  5. poj 1905 Expanding Rods 二分

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

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

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

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

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

  8. 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 ...

  9. POJ 1905 Expanding Rods(二分)

    Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 20224 Accepted: 5412 Descr ...

随机推荐

  1. PHP多维数组去重

    自己写了一个实现多维数组去重的方法, 只是实现了功能, 至于性能没多管~  可以保留key, 这个方法是针对最终的一维数组元素去重, 如果是多维数组的两个子元素是相同的数组, 是不能去重的 prote ...

  2. Codevs 1298 凸包周长

    1298 凸包周长 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond 题目描述 Description 给出平面上n个点,求出这n个点形成的凸包的周长. 凸包的定 ...

  3. 利用Python构建时间序列模型解决实际问题的正确姿势

    要本着应用到实际工作中目的去学时间序列分析,才能深入浅出的学会,不要纠结于理论,只听我的,我有信心说明白. 本章内容 趋势分析 序列分解 序列预测 序列分解 统计学基础铺垫 划分 时间序列按照季节性划 ...

  4. c 判断是否为非控制字符

    #include <stdio.h> #include <wctype.h> int main () { ; wchar_t str[] = L"first line ...

  5. vue 编译大量空格警告问题总结 warning: Replace `↹↹` with `&#183;&#183;`

    1.vue开发中发现最后越来越多的编译警告,如 warning: Replace `↹↹` with `··` (prettier/prettier) at src/views/shebei/shou ...

  6. 引发了未经处理的异常:读取访问权限冲突。 _First 是 nullptr。

    1.问题:程序崩溃出现错误 引发了未经处理的异常:读取访问权限冲突. _First 是 nullptr. string strreponse=0: 定义这条语句,字符串初始化错误. 自己开发了一个股票 ...

  7. java线程基础方法详解

    一.线程状态转换 1.新建状态(New):新创建了一个线程对象. 2.就绪状态(Runnable):线程对象创建后,其他线程调用了该对象的start()方法.该状态的线程位于可运行线程池中,变得可运行 ...

  8. Leetcode题目101.对称二叉树(简单)

    题目描述: 给定一个二叉树,检查它是否是镜像对称的. 例如,二叉树 [1,2,2,3,4,4,3] 是对称的. 1 / \ 2 2 / \ / \ 3 4 4 3 但是下面这个 [1,2,2,null ...

  9. 处理flutter http请求添加application/json报错Cannot set the body fields of a Request with content-type “application/json”

    在flutter中在http请求发送时设置"content-type": "application/json"会出现报错Cannot set the body ...

  10. DNA Sorting

    DNA Sorting Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 105159   Accepted: 42124 De ...