UVA 10668 - Expanding Rods

题目链接

题意:给定一个铁棒,如图中加热会变成一段圆弧,长度为L′=(1+nc)l,问这时和原来位置的高度之差

思路:画一下图能够非常easy推出公式,设圆弧扇形部弧度r,那么能够计算出铁棒长度为lr/sin(r)这个公式在[0,
pi/2]是单调递增的,所以能够用二分法去求解

要注意的一点是最后答案计算过程中带入mid,之前是带入x(二分的左边值),可实际上x是可能等于0的,而带入mid,因为是double型,所以mid实际上表示是一个很趋近0的数字,而不是0.

代码:

#include <cstdio>
#include <cstring>
#include <cmath> const double pi = acos(-1.0); double l, n, c; double cal(double r) {
return l / sin(r) * r;
} int main() {
while (~scanf("%lf%lf%lf", &l, &n, &c)) {
if (l < 0) break;
double x = 0, y = pi / 2, lx = (1 + n * c) * l, m;
for (int i = 0; i < 100; i++) {
m = (x + y) / 2;
if (cal(m) < lx) x = m;
else y = m;
}
printf("%.3lf\n", l / 2 / sin(m) * (1 - cos(m)));
}
return 0;
}

UVA 10668 - Expanding Rods(数学+二分)的更多相关文章

  1. UVA 10668 Expanding Rods

    Problem A: Expanding Rods When a thin rod of length L is heated n degrees, it expands to a new lengt ...

  2. POJ 1905 Expanding Rods(二分)

    Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 20224 Accepted: 5412 Descr ...

  3. LightOj1137 - Expanding Rods(二分+数学)

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1137 题意:有一根绳子的长度为l,在有温度的情况下会变形为一个圆弧,长度为 l1 = ...

  4. poj 1905 Expanding Rods (数学 计算方法 二分)

    题目链接 题意:将长度为L的棒子卡在墙壁之间.现在因为某种原因,木棒变长了,因为还在墙壁之间,所以弯成了一个弧度,现在求的是弧的最高处与木棒原先的地方的最大距离. 分析: 下面的分析是网上别人的分析: ...

  5. POJ - 1905 Expanding Rods(二分+计算几何)

    http://poj.org/problem?id=1905 题意 一根两端固定在两面墙上的杆,受热后变弯曲.求前后两个状态的杆的中点位置的距离 分析 很明显需要推推公式. 由②的限制条件来二分角度, ...

  6. poj1905 Expanding Rods(二分)

    题目链接:https://vjudge.net/problem/POJ-1905 题意:有一根长len的木棍,加热了n度,长度会膨胀为len*(1+n*c),c为膨胀系数.现在把这根木棍夹在两堵墙之间 ...

  7. poj 1905 Expanding Rods(木杆的膨胀)【数学计算+二分枚举】

                                                                                                         ...

  8. 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 ...

  9. POJ 1905:Expanding Rods 求函数的二分

    Expanding Rods Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 13780   Accepted: 3563 D ...

随机推荐

  1. Entity Framework 级联删除

    为一对主从表增加级联删除功能 protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.E ...

  2. Centos6.2_(64位)服务器环境配置:源码编译Nginx

    目标软件都指定安装目录:/apps.由于Nginx可以使用正则表达式来匹配访问路径, 要正常使用此功能就保证安装有Pcre库,如果你已经接着上一篇操作过来,就可以不用考虑这一点,因为此库已经在安装列表 ...

  3. PHPCMS get当中使用limit

    最近在用PHPCMS V9做一个站子,发现get标签非常好用,自定义模型后get几乎变成万能的了.但是PHPCMS升级到V9后,把2008的很多功能都去掉了,比如get标签中,在后面自动添加了一个LI ...

  4. Perl常用特殊变量

    perl 内置变量 $- 当前页可打印的行数,属于Perl格式系统的一部分 $! 根据上下文内容返回错误号或者错误串 $” 列表分隔符 $# 打印数字时默认的数字输出格式 $$ Perl解释器的进程I ...

  5. qt实现头像上传功能(朝十晚八的博客,一堆帖子)

    http://www.cnblogs.com/swarmbees/p/5688885.html

  6. left join 、right join 、inner join和 full join的区别

    内连接      INNER JOIN(等值连接):只显示两个表中联结字段相等的行.这个和用select查询多表是一样的效果,所以很少用到: 外连接:LEFT JOIN :以左表为基础,显示左表中的所 ...

  7. If one session has a shared or exclusive lock on record R in an index, another session cannot insert

    If one session has a shared or exclusive lock on record R in an index, another session cannot insert ...

  8. 【HDOJ】1483 Automatic Correction of Misspellings

    水模拟题. /* 1483 */ #include <cstdio> #include <cstring> #include <cstdlib> #define M ...

  9. Linux&shell 之Shell命令进阶

    写在前面:案例.常用.归类.解释说明.(By Jim) 监控程序a.进程查看ps -ef(-e表示系统上运行的所有进程,-f用于扩展输出一些有用的信息列.)ps -efH(-H参数可以将进程组织为分层 ...

  10. Oracle用户管理

    创建用户 概述:在oracle中要创建一个新的用户使用create user 语句,一般是具有dba(数据库管理员)的权限才能使用. create user 用户名 identified by 密码: ...