Expanding Rods POJ 1905 二分
| Time Limit: 1000MS | Memory Limit: 30000K | |
| Total Submissions: 17050 | Accepted: 4503 |
Description
When a thin rod of length L is heated n degrees, it expands to a new length L'=(1+n*C)*L, where C is the coefficient of heat expansion. 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
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
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<sstream>
#include<algorithm>
#include<queue>
#include<deque>
#include<iomanip>
#include<vector>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<fstream>
#include<memory>
#include<list>
#include<string>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MAXN 20009
#define N 21
#define MOD 1000000
#define INF 1000000009
const double eps = 1e-;
const double PI = acos(-1.0);
/*
给一个弦长和弧长 求圆心到弦的距离 直接求不太好求
可以用二分搜索
为了避免精度损失应该 尽量少用除法! 一开始想枚举弧度有点跑偏。。
因为枚举弧度 :sgn(L*x - 2 * l*sin(x / 2)) == 0 这个表达式判断失败后不好分析下一步二分的范围
还是直接枚举H h越小 弧长越大
*/
double L, c, n, l;
inline int sgn(double x)
{
//cout << x << endl;
if (fabs(x - ) < eps)
return ;
else if (x > )
return ;
else
return -;
}
int main()
{
while (scanf("%lf%lf%lf", &L, &c, &n), !(L<&&c<&&n<))
{
l = ( + n*c)*L;
double beg = , end = L/;
while (sgn(end - beg) > )
{
double mid = (beg + end) / ;
double r = ( * mid*mid + L*L) / / mid;
//cout << ":" << mid << endl;
if (sgn(*r*asin(L//r)-l) < )//弧长应当加大,所以h应该减小
{
beg = mid;
}
else
end = mid;
}
printf("%.3lf\n", beg);
}
}
Expanding Rods POJ 1905 二分的更多相关文章
- 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 ...
- 【二分答案】Expanding Rods POJ 1905
题目链接:http://poj.org/problem?id=1905 题目大意:原长度为L的线段因受热膨胀为一段弧,线段L.弧长L'.温度n.膨胀率c满足L' =(1+n/c)*L;求线段的中点移动 ...
- poj 1905 Expanding Rods (数学 计算方法 二分)
题目链接 题意:将长度为L的棒子卡在墙壁之间.现在因为某种原因,木棒变长了,因为还在墙壁之间,所以弯成了一个弧度,现在求的是弧的最高处与木棒原先的地方的最大距离. 分析: 下面的分析是网上别人的分析: ...
- POJ 1905:Expanding Rods 求函数的二分
Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 13780 Accepted: 3563 D ...
- POJ 1905 Expanding Rods(二分)
Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 20224 Accepted: 5412 Descr ...
- poj 1905 Expanding Rods(木杆的膨胀)【数学计算+二分枚举】
...
- POJ 1905 Expanding Rods
Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 1 ...
- UVA 10668 - Expanding Rods(数学+二分)
UVA 10668 - Expanding Rods 题目链接 题意:给定一个铁棒,如图中加热会变成一段圆弧,长度为L′=(1+nc)l,问这时和原来位置的高度之差 思路:画一下图能够非常easy推出 ...
- Expanding Rods(二分POJ1905)
Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 13688 Accepted: 3527 D ...
随机推荐
- js获取request参数值(javascript 获取request参数值的方法)
jsp 中的js,可以用el表达式来提取:var value = "${requestScope.XXX}"; 注:XXX为你的参数名 如:http://localhost:808 ...
- 一、Linux文件权限与目录配置
行文结构如下: 用户和用户组 Linux文件权限概念 Linux目录配置 重点回顾 1.用户与用户组 Linux是个多用户.多任务的系统,可能有多人同时使用这台机器进行工作,为了考虑每个人的隐私和工作 ...
- windows2003下svn的安装
Windows2003下svn平台搭建 编辑:dnawo 日期:2010-08-03 转自http://www.mzwu.com/article.asp?id=2557 字体大小: 小 中 大 ...
- iis 服务器而配置php运行环境
第一步 下载php 下载压缩包就可以了 第二步 解压缩php到某个目录,比如D:\php php目录里面有两个php.ini,一个是php.ini-dist,比较适合开发用:一个是php.ini-re ...
- centos6.6安装redis
.安装仓库 yum install epel-release -y2.安装redis yum install redis -y3.程序文件说明 安装完毕后有以下几个文件位于/usr/bin目录: re ...
- HDU 3007 最小圆覆盖 计算几何
思路: 随机增量法 (好吧这数据范围并不用) //By SiriusRen #include <cmath> #include <cstdio> #include <al ...
- 第10篇 WINDOWS2003服务器 IIS上配置404页面的图文教程
打开IIS 找到你的网站,点右键,选择属性 选择“自定义错误”标签页,找到404的那一项,点“编辑属性”按钮 (方案一)在“消息类型”里选“URL”,然后在下面的“URL”输入框里,填上你的404错误 ...
- mysql数据的操作
一.插入数据记录 1.插入完整数据记录 INSERT INTO table_name VALUES(value1,value2......valuen); 2.插入数据记录的一部分 INSERT IN ...
- centos mysql允许远程root登录
Mysql为了安全性,在默认情况下用户只允许在本地登录,可是在有此情况下,还是需要使用用户进行远程连接,因此为了使其可以远程需要进行如下操作: 一.允许root用户在任何地方进行远程登录,并具有所有库 ...
- Android基于HttpUrlConnection类的文件下载
/** * get方法的文件下载 * <p> * 特别说明 android中的progressBar是google唯一的做了处理的可以在子线程中更新UI的控件 * * @param pat ...