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(木杆的膨胀)【数学计算+二分枚举】
...
随机推荐
- JAVA字符串的GZIP压缩解压缩
package com.gzip; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import ...
- Lintcode: Count of Smaller Number
Give you an integer array (index from 0 to n-1, where n is the size of this array, value from 0 to 1 ...
- Servlet 基础认识 使用
参考书<JSP Web 开发案例教程> 在jsp项目中的src文件下面创建HelloServletTest.java,代码如下,注意src的包名,我的包名是zhbit.com packag ...
- HDU 1890 区间反转
http://acm.hdu.edu.cn/showproblem.php?pid=1890 Robotic Sort Problem Description Somewhere deep in th ...
- 事务——sql server中的事务应用举例
sql中事务只针对一个update,delete,insert语句,如果一段程序中有超过一个这样的语句,就需要每个都判断是否出错,否则就会出现若干我们不希望的情形出现,举例如下(表结构见最后): 1, ...
- java经典小算法
package com.shb.java; public class Demo4 { /**时间有限 先不写文字了 自己随便敲的 * @param args * @author shaobn */ p ...
- sql 存储过程参数是表类型,数据库中如何调用
DECLARE @NEW_STUDENT as [CancelLendersContent] INSERT @NEW_STUDENT VALUES (0,0,0,'12345678912','张三', ...
- 最懂中文的H5前端框架amazeUI
Amaze UI 是一个轻量级(所有 CSS 和 JS gzip 后 100 kB 左右)的前端框架, 基于开源社区流行前端框架编写 amazeUI的网址:http://amazeui.org/get ...
- hadoop文件系统FileSystem详解 转自http://hi.baidu.com/270460591/item/0efacd8accb7a1d7ef083d05
Hadoop文件系统 基本的文件系统命令操作, 通过hadoop fs -help可以获取所有的命令的详细帮助文件. Java抽象类org.apache.hadoop.fs.FileSystem定义了 ...
- spring的定时任务
maven中引入quartz的jar包依赖 单纯针对时间的设置规则org.springframework.scheduling.quartz.CronTriggerBean允许你更精确地控制任务的运行 ...