Expanding Rods(二分POJ1905)
Time Limit: 1000MS | Memory Limit: 30000K | |
Total Submissions: 13688 | Accepted: 3527 |
Description
When a thin rod is mounted on two solid walls and then heated, it expands and takes the shape of a circular segment, the original rod being the chord of the segment.
Your task is to compute the distance by which the center of the rod is displaced.
Input
data guarantee that no rod expands by more than one half of its original length. The last line of input contains three negative numbers and it should not be processed.
Output
Sample Input
1000 100 0.0001
15000 10 0.00006
10 0 0.001
-1 -1 -1
Sample Output
61.329
225.020
0.000
Source
写了三个公式acos过不了,后来金巨说asin和acos产生的误差atan要大
#include <set>
#include <map>
#include <list>
#include <stack>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define PI acos(-1.0)
using namespace std; typedef long long LL; const int MAX = 50010; const double eps = 1e-5; double l,c,n;
double ll;
bool Judge(double mid)
{
double r=(l*l+4*mid*mid)/(8*mid);
double dis=2*r*asin(l/(2*r));
//atan(l/(2*(r-mid)));
if(dis<ll)
{
return true;
}
else
{
return false;
}
} int main()
{
while(scanf("%lf %lf %lf",&l,&n,&c))
{
if(l==-1&&c==-1&&n==-1)
{
break;
}
ll=(1+n*c)*l;
double L=0;
double R=l/2;
double ans=0;
while(R-L>eps)
{
double mid = (L+R)/2;
if(Judge(mid))
{
ans=mid;
L=mid;
}
else
{
R=mid;
}
}
printf("%.3f\n",ans);
}
return 0;
}
Expanding Rods(二分POJ1905)的更多相关文章
- 二分法 (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 ...
- poj 1905 Expanding Rods(木杆的膨胀)【数学计算+二分枚举】
...
随机推荐
- IntelliJ IDEA Community Edition 14.1.4下 javafx scenebuilder的使用
官网对应的配置文档:https://www.jetbrains.com/idea/help/preparing-for-javafx-application-development.html Java ...
- java io读书笔记(6) Writing Arrays of Bytes
显而易见,一次性写出一堆数据,要比一个byte一个byte的写,快多了,因此,outputstream,给出了2个增强型的write: public void write(byte[] data) t ...
- ui方案设计
最近在做一个ui,前端,为了引出创意,万事开头难,记录一下: 算是单页吧,一般都是左侧是导航,右边是内容,单页的话,要记录标签关闭,窗口区域. 操作的连惯性等.UI设计是个细活,需要深加研究,以后补充 ...
- ant的那些闹挺事
今日发现了一个问题,用ant+hudson去运行脚本代码时,突然ant报错: 即使我在ant的build文件中指定了basedir=“C:/Users/145064/.hudson/jobs/haix ...
- 常见http代码错误原因及处理
常见的HTTP错误可以分为以下四大类.每一大类又细分为很多类小错误.当您打不开网站或者打开网站报错时首先检查您输入的网站是否有误,检查网络是否有问题或者虚拟主机的DNS是否可以解析.确定没有问题时再看 ...
- CSS_01_css和html的结合1、2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- php session session_set_save_handler 接管所有的session管理工作
一个已知管用的方法是,使用session_set_save_handler,接管所有的session管理工作,一般是把session信息存储到数 据库,这样可以通过SQL语句来删除所有过期的sessi ...
- 解决Android抽屉被击穿问题
1,创建一个抽屉DrawerLayout,在V4包下android.support.v4.widget.DrawerLayout,在要设置抽屉的布局中设置android:layout_gravity= ...
- HttpUtility.HtmlEncode 方法
將字串轉換為 HTML 編碼的字串. 例如: publicstringWelcome(string name,int numTimes =1){ returnHttpUtility.HtmlE ...
- 夺命雷公狗---微信开发58----微网站之jquery_mobile之控件介绍
我们上一节课里面介绍了基本的jqm是如何用的了,那么这一节课我们就开始玩玩他的控件 1...布局网格 <!DOCTYPE html> <html> <head> & ...