Problem A: Expanding Rods

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.

The input contains multiple lines. Each line of input contains three non-negative numbers: the initial lenth of the rod in millimeters, the temperature change in degrees and the coefficient of heat expansion of the material. 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.

For each line of input, output one line with the displacement of the center of the rod in millimeters with 3 digits of precision.

Sample input

1000 100 0.0001
15000 10 0.00006
10 0 0.001
-1 -1 -1

Output for sample input

61.329
225.020
0.000 二分法:二分高度H,计算出H对应的L弧长来推出答案 弧长根据补出一个园三角函数推出弧长即可
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MAXN 10000+10
#define INF 1<<30
int MOD;
double l, n, c; double getL(double h){
double R = l*l/(8*h)+h/2;
return asin(l/(2*R))*(2*R);
} int main (){ while(scanf("%lf%lf%lf",&l, &n, &c) != EOF){
if(l < 0 && n < 0 && c < 0)
break;
double L = 0, R = l/2;
double tar = (1+n*c)*l;
for(int i = 0; i < 100; i++){
double mid = (L+R)/2;
if(getL(mid) < tar)
L = mid;
else
R = mid;
}
printf("%.3lf\n",L);
}
return 0;
}

  

UVA 10668 Expanding Rods的更多相关文章

  1. UVA 10668 - Expanding Rods(数学+二分)

    UVA 10668 - Expanding Rods 题目链接 题意:给定一个铁棒,如图中加热会变成一段圆弧,长度为L′=(1+nc)l,问这时和原来位置的高度之差 思路:画一下图能够非常easy推出 ...

  2. POJ 1905 Expanding Rods

                           Expanding Rods Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 1 ...

  3. Expanding Rods(二分POJ1905)

    Expanding Rods Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 13688   Accepted: 3527 D ...

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

                                                                                                         ...

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

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

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

  7. POJ 1905 Expanding Rods(二分)

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

  8. 1137 - Expanding Rods

    1137 - Expanding Rods    PDF (English) Statistics Forum Time Limit: 0.5 second(s) Memory Limit: 32 M ...

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

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

随机推荐

  1. MySQL☞length函数

    length(字符串/列名):求出该字符串/列名中字符的个数 格式: select  length(列名)  from 表名 如下图:

  2. python QQ邮箱自动发送邮件

    于初学者来讲在写发送邮件代码时常见的错误有SMTPAuthenticationError535,有点懵逼,检查用户名,密码正确就是报错, 想当年笔者也是这么过来的,现在就给大家分享一下个人经验: 一, ...

  3. Nginx 配置 HTTPS自签名证书

    工具: OpenSSL ssl的开源实现,几乎实现了市面上所有的加密 libcrypto: 通用加密库, 任何软件要实现加密功能 链接调用这个库 libssl: TLS/SSL 加密库 openssl ...

  4. LeetCode 707 ——设计链表

    1. 题目 2. 解答 用一个单链表来实现,只有一个头指针.因为不能建立哨兵结点,因此要特别注意是否在头结点处操作. class MyLinkedList { public: struct ListN ...

  5. 使用idea工具开发webservice

    在idea开发工具中使用axis2插件创建集成webservice的web项目: 一.创建java项目                  二.添加webservices支持 在红线框2处选择要使用的w ...

  6. liniux备忘录-磁盘配额与进阶文件系统管理

    知识 磁盘配额Quota 可以限制磁盘的使用容量,可以对用户.群组磁盘的最大使用容量. 磁盘配额Quota的使用限制 只能针对整个文件系统. 核心必须支持Quota. 自行编译的核心需要注意 Quot ...

  7. C++STL——map

    一.相关定义 map 关联容器,存储相结合形成的一个关键值和映射值的元素 提供一对一(第一个可以称为关键字,每个关键字只能在map中出现一次,第二个可以称为该关键字的值)的数据处理能力 map对象是模 ...

  8. 二分图最大权匹配:Kuhn-Munkres算法

    http://www.cnblogs.com/kuangbin/archive/2012/08/19/2646535.html

  9. winform自动最大化(在不同分辨率情况下)

    load函数末尾加: System.Drawing.Rectangle rec = Screen.GetWorkingArea(this); int SH = rec.Height; int SW = ...

  10. 【Python】Python内置函数dir详解

    1.命令介绍 最近学习并使用了一个python的内置函数dir,首先help一下: 复制代码代码如下: >>> help(dir)Help on built-in function ...