poj 1905 Expanding Rods (数学 计算方法 二分)
2014-07-25 16:45
316 查看
题目链接
题意:将长度为L的棒子卡在墙壁之间。现在因为某种原因,木棒变长了,因为还在墙壁之间,所以弯成了一个弧度,现在求的是弧的最高处与木棒原先的地方的最大距离。
分析:
下面的分析是网上别人的分析:
设弦长为L0(即原长),弧长为L1=(1+n*C)*l0,目标值为h,半径为R,弧所对圆心角为2θ(弧度制)。
可以得到以下方程组:
圆的弧长公式:L1=2θR
三角函数公式:L0=2*R*sinθ,变换得θ=arcsin(L0/(2*R))
勾股定理:R^2=(R-h)^2+(0.5*L0)^2,变换得L0^2+4*h^2=8*h*R
合并①②式得到
L1=2*R*arcsin(L0/(2*R))
半径R可以由③式变换得到
R=(L0^2+4*h^2)/(8*h)
可以用二分枚举h的值,计算出R和L1,与题目中L1进行比较。
题意:将长度为L的棒子卡在墙壁之间。现在因为某种原因,木棒变长了,因为还在墙壁之间,所以弯成了一个弧度,现在求的是弧的最高处与木棒原先的地方的最大距离。
分析:
下面的分析是网上别人的分析:
设弦长为L0(即原长),弧长为L1=(1+n*C)*l0,目标值为h,半径为R,弧所对圆心角为2θ(弧度制)。
可以得到以下方程组:
圆的弧长公式:L1=2θR
三角函数公式:L0=2*R*sinθ,变换得θ=arcsin(L0/(2*R))
勾股定理:R^2=(R-h)^2+(0.5*L0)^2,变换得L0^2+4*h^2=8*h*R
合并①②式得到
L1=2*R*arcsin(L0/(2*R))
半径R可以由③式变换得到
R=(L0^2+4*h^2)/(8*h)
可以用二分枚举h的值,计算出R和L1,与题目中L1进行比较。
#include <iostream> #include <cstring> #include <cstdlib> #include <cmath> #include <cstdio> #include <vector> #include <algorithm> #define LL long long using namespace std; const double eps = 1e-8; int main() { double l0, n, c, l1, l2, r; double high, low, mid; while(cin>>l0>>n>>c) { if(l0==-1&&n==-1&&c==-1) break; l1 = (1+n*c)*l0; low = 0; high = 0.5*l0; while(high-low>eps) { mid = (low+high)/2; r = (l0*l0 + 4*mid*mid)/(8*mid); l2 = 2*r*asin(l0/(2*r)); if(l1 < l2) high = mid; else low = mid; } mid = (low+high)/2; printf("%.3lf\n", mid); } return 0; }
相关文章推荐
- poj 1905 Expanding Rods(木杆的膨胀)【数学计算+二分枚举】
- POJ1905 Expanding Rods(计算几何推公式+二分)
- POJ 1905 Expanding Rods 二分加数学公式的推导
- POJ - 1905 Expanding Rods (数学+二分)
- POJ 题目1905 Expanding Rods(二分,数学几何)
- POJ-1905-Expanding Rods【二分】【计算几何】
- POJ 1905 Expanding Rods 二分答案几何
- Expanding Rods(POJ--1905【二分查找】
- poj1905 Expanding Rods 二分
- poj 1905 Expanding Rods(二分)
- POJ-1905 Expanding Rods 解题报告(二分) 金属材料的膨胀
- Expanding Rods(二分POJ1905)
- 二分 poj1905 Expanding Rods
- poj 1905 Expanding Rods 二分答案
- POJ 1905 Expanding Rods 几何加二分
- POJ 1905 Expanding Rods几何题,二分
- Expanding Rods(二分POJ1905)
- POJ 1905 Expanding Rods(几何+二分)
- POJ 1905 Expanding Rods【二分答案】
- poj 1905 Expanding Rods (二分查找)