poj1905 Expanding Rods(二分)
题目链接: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(二分)的更多相关文章
- Expanding Rods(二分POJ1905)
Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 13688 Accepted: 3527 D ...
- 二分法 (UVA10668 Expanding Rods)(二分+几何)
转载请注明出处:優YoU http://user.qzone.qq.com/289065406/blog/1301845324 大致题意: 一根两端固定在两面墙上的杆 受热弯曲后变弯曲.求前后两个状态 ...
- Expanding Rods(二分)
Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 10287 Accepted: 2615 Description When ...
- POJ 1905 Expanding Rods 二分答案几何
题目:http://poj.org/problem?id=1905 恶心死了,POJ的输出一会要lf,一会要f,而且精度1e-13才过,1e-12都不行,错了一万遍终于对了. #include < ...
- poj 1905 Expanding Rods 二分
/** 题解晚上写 **/ #include <iostream> #include <math.h> #include <algorithm> #include ...
- UVA 10668 - Expanding Rods(数学+二分)
UVA 10668 - Expanding Rods 题目链接 题意:给定一个铁棒,如图中加热会变成一段圆弧,长度为L′=(1+nc)l,问这时和原来位置的高度之差 思路:画一下图能够非常easy推出 ...
- POJ 1905:Expanding Rods 求函数的二分
Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 13780 Accepted: 3563 D ...
- 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 ...
- POJ 1905 Expanding Rods(二分)
Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 20224 Accepted: 5412 Descr ...
随机推荐
- Luogu P4398 [JSOI2008]Blue Mary的战役地图 矩阵哈希
其实可以二分矩阵边长但是我太懒了$qwq$. 把每个子矩阵扔到$map$里,然后就没了 #include<cstdio> #include<map> #include<i ...
- PHP mysqli_more_results() 函数
定义和用法 mysqli_more_results() 函数检查一个多查询是否有更多的结果. 语法 mysqli_more_results(connection); 参数 描述 connection ...
- HGOI 20191031am 题解
Problem A Divisors 给出$m$个不同的正整数$a_i$,设数论函数 $f(k) = \sum\limits_{i = 1}^{n} [(\sum\limits_{j = 1}^ ...
- neo4j 一些常用的CQL
创建节点.关系 创建节点(小明):create (n:people{name:’小明’,age:’18’,sex:’男’}) return n; 创建节点(小红): create (n:people{ ...
- ie8中如何使用base64
由于ie8中不能使用jQuery2.0以上版本所以无法使用 window.btoa()加密 window.atob()解密 所以只能使用最原生的base64加密方法如下: /** * Created ...
- Codeforces 576D Flights for Regular Customers (图论、矩阵乘法、Bitset)
题目链接 http://codeforces.com/contest/576/problem/D 题解 把边按\(t_i\)从小到大排序后枚举\(i\), 求出按前\((i-1)\)条边走\(t_i\ ...
- sprintf简介
sprintf 基本用法 输入一段有特点的字符串 #include <cstdio> #include <cstring> using namespace std; int m ...
- CISCO实验记录三:CDP邻居发现
一.CDP邻居发现要求 1.识别二层连接 2.识别CDP邻居 二.CDP邻居发现操作 1.CDP邻居发现 #interface gigabitEthernet 0/0/0 //启动端口 #no shu ...
- 使用Pillow(PIL)库实现中文字符画
上班摸鱼写的,不多说了,直接上脚本 #coding=utf-8 from PIL import Image from PIL import ImageDraw from PIL import Imag ...
- docker 用nginx 部署 node应用
1.查询镜像 # 1.查询镜像. docker search nginx 2.拉取指定的镜像 # 2.拉取指定的镜像 docker pull nginx 3.下载完成后终端查看 # 3.下载完成后终 ...