poj 1905 Expanding Rods (数学 计算方法 二分)
题意:将长度为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-; int main()
{
double l0, n, c, l1, l2, r;
double high, low, mid;
while(cin>>l0>>n>>c)
{
if(l0==-&&n==-&&c==-) break;
l1 = (+n*c)*l0;
low = ; high = 0.5*l0;
while(high-low>eps)
{
mid = (low+high)/;
r = (l0*l0 + *mid*mid)/(*mid);
l2 = *r*asin(l0/(*r));
if(l1 < l2) high = mid;
else low = mid;
}
mid = (low+high)/;
printf("%.3lf\n", mid);
}
return ;
}
poj 1905 Expanding Rods (数学 计算方法 二分)的更多相关文章
- poj 1905 Expanding Rods(木杆的膨胀)【数学计算+二分枚举】
...
- POJ 1905 Expanding Rods(二分)
Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 20224 Accepted: 5412 Descr ...
- POJ 1905 Expanding Rods
Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 1 ...
- POJ - 1905 Expanding Rods(二分+计算几何)
http://poj.org/problem?id=1905 题意 一根两端固定在两面墙上的杆,受热后变弯曲.求前后两个状态的杆的中点位置的距离 分析 很明显需要推推公式. 由②的限制条件来二分角度, ...
- 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 ...
- POJ 1905 Expanding Rods 木棍膨胀
描述 当长度为L的一根细木棍的温度升高n度,它会膨胀到新的长度L'=(1+n*C)*L,其中C是热膨胀系数. 当一根细木棍被嵌在两堵墙之间被加热,它将膨胀形成弓形的弧,而这个弓形的弦恰好是未加热前木棍 ...
- POJ 1905 Expanding Rods (求直杆弯曲拱起的高度)(二分法,相交弦定理)
Description When a thin rod of length L is heated n degrees, it expands to a new length L' = (1+n*C) ...
- POJ 1905 Expanding Rods( 二分搜索 )
题意:一个钢棍在两面墙之间,它受热会膨胀成一个圆弧形物体,这个物体长 S = ( 1 + n * C ) * L,现在给出原长 L ,温度改变量 n ,和热膨胀系数 C,求膨胀后先后中点的高度差. 思 ...
随机推荐
- 被git extensions给坑了,Not owner 解决办法
我只遇到这一种情况,不能访问git文件主库, 清空以前的历史文件,包括默认配置文件,重新安装一遍git extension,然后设置账号和密码, 在打开bash设置私钥和公钥 把公钥添加到你的git的 ...
- Eclipse中创建标准web工程以及标准目录结构说明
最近公司有个Web项目,项目结构如下: 虽然运行没有错,但是实在是别扭,标准的web应用一般不采用这种结构: 因此总结一下: 1.如何在Eclipse中创建一个标准的Web应用. 2. ...
- Matlab中find函数的使用
一.问题来源 看到了 min_score_pos = find(A0_scores==min(A0_scores), 1); [r,c] = find(X,k),返回X中第k个非零元素的行列位置. 二 ...
- SQL Server 之 DBCC
--检查索引碎片情况 dbcc showconfig(tablename) 具体例子: --上图为碎片整理之前 ALTER INDEX ALL on Citation REBUILD --下图为碎片整 ...
- 数据库范式(1NF 2NF 3NF BCNF)
http://blog.csdn.net/xuxurui007/article/details/7738330 http://www.cnblogs.com/laodao1/archive/2009/ ...
- java web项目 。classpath 文件解析
eclipse工程中.classpath文件含义: 下面是一个.classpath文件内容: < ?xml version="1.0" encoding="UTF- ...
- Application.persistentDataPath 的一个小坑
打包之前在Android的Player Setting里面选择WriteAccess (写入访问) Internal Only:表示Application.persistentDataPath的路径是 ...
- Asp.net MVC4.0自定义Html辅助方法
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.W ...
- Android 父类super.onDestroy();的有关问题
super.onDestroy(); 的问题. 注意:没有显式地在自己的方法中调用父类Activity的onDestroy是会报错的.我的问题很简单,在我覆盖的onDestroy(),方法中需要调用父 ...
- Android 用Activity的onTouchEvent来监听滑动手势
package com.example.activityOnTouchEvent; import android.app.Activity; import android.os.Bundle; imp ...