POJ1905Expanding Rods(二分)
http://poj.org/problem?id=1905
题意 :在两堵实心墙中间有一根杆,长度为L,然后给它加热,温度是n,则两墙之间的杆会弯曲,长度会变为L'=(1+n*C)*L,求前后两个状态杆的中心位置的距离
思路 :一部分几何加上最主要的二分 。这个我发现小优姐写的特别好,分析的也很完美,我就不再多解释了,发一下链接吧http://blog.csdn.net/lyy289065406/article/details/6648562
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std ;
const double eps = 1e- ;
int main()
{
double l,tem,c ;
while(scanf("%lf %lf %lf",&l,&tem,&c)!=EOF)
{
if(l == -&&tem == -&&c == -)
break ;
double s = (+tem*c)*l ;
double low = 0.0 ;
double high = 0.5*l ;
double mid ;
while(high - low > eps)
{
mid = (low+high)/;
double r = (*mid*mid+l*l)/(*mid) ;
if((*r*asin(l/(*r))) < s)
low = mid ;
else high = mid ;
}
printf("%.3lf\n",mid) ;
}
return ;
}
对于代码中对最小精度的规定,不能太小,若是太小的话,循环次数容易增多,会超时,一般到1e-10就是TLE,不过5到8都是0ms过的,所以要注意以下,还有一个要注意的点是二分循环不能直接用<=这样的话会陷入死循环,因为都是double类型的。
POJ1905Expanding 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 ...
随机推荐
- Oracle用户system解锁
1.首先进入sql plus窗口(参见上一篇文章) 2.进入后:输入select username,account_status from dba_users where username='SYST ...
- [android]netd与NetworkManagementService初印象
[功能]Netd是什么,主要负责什么功能 为什么这次会接触Netd主要是因为在设置防火墙时候碰到了.关于Netd可以干什么可以从Netd的源码中CommandListener中得到答案.按照我的理解, ...
- Poj 3239 Solution to the n Queens Puzzle
1.Link: http://poj.org/problem?id=3239 2.Content: Solution to the n Queens Puzzle Time Limit: 1000MS ...
- Spring多数据源的动态切换
Spring多数据源的动态切换 目前很多项目中只能配置单个数据源,那么如果有多个数据源肿么办?Spring提供了一个抽象类AbstractRoutingDataSource,为我们很方便的解决了这个问 ...
- coreseek安装使用
本文引自:http://www.phperz.com/article/14/0615/95.html sphinx的安装使用,其实都是大同小异,以下以 coreseek安装为例Coreseek 是一款 ...
- Winform程序只允许运行一个程序实例
/// <summary> /// 应用程序的主入口点. /// </summary> [STAThread] static void Main() { Application ...
- python 对象持久化 pickle模块
用到python 序列化 比如我们可以把一些配置的信息放到数组,字典或者做为类的属性,然后对数据进行 序列化,再把序列化好的数据放到文件里或者直接放到数据库里,这样可以方便下次要用数据的时候 对数据进 ...
- The Best Rank (25)(排名算法)
To evaluate the performance of our first year CS majored students, we consider their grades of three ...
- 2016 Multi-University Training Contest 1 Necklace 环排+二分匹配
链接:http://acm.hdu.edu.cn/showproblem.php?pid=5727 题意:由2*N颗宝石构成的环(阴阳宝石均为N颗且标号均从1~N) 之后给定M组 a,b;表示阳宝石a ...
- php生成xml的四种方法(转)
<?xml version="1.0" encoding="utf-8"?> <article> <item> <ti ...