UVA 10668 Expanding Rods
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的更多相关文章
- UVA 10668 - Expanding Rods(数学+二分)
UVA 10668 - Expanding Rods 题目链接 题意:给定一个铁棒,如图中加热会变成一段圆弧,长度为L′=(1+nc)l,问这时和原来位置的高度之差 思路:画一下图能够非常easy推出 ...
- POJ 1905 Expanding Rods
Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 1 ...
- Expanding Rods(二分POJ1905)
Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 13688 Accepted: 3527 D ...
- poj 1905 Expanding Rods(木杆的膨胀)【数学计算+二分枚举】
...
- POJ 1905:Expanding Rods 求函数的二分
Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 13780 Accepted: 3563 D ...
- 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 ...
- POJ 1905 Expanding Rods(二分)
Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 20224 Accepted: 5412 Descr ...
- 1137 - Expanding Rods
1137 - Expanding Rods PDF (English) Statistics Forum Time Limit: 0.5 second(s) Memory Limit: 32 M ...
- LightOj1137 - Expanding Rods(二分+数学)
题目链接:http://lightoj.com/volume_showproblem.php?problem=1137 题意:有一根绳子的长度为l,在有温度的情况下会变形为一个圆弧,长度为 l1 = ...
随机推荐
- python 基础篇 11 函数进阶----装饰器
11. 前⽅⾼能-装饰器初识本节主要内容:1. 函数名的运⽤, 第⼀类对象2. 闭包3. 装饰器初识 一:函数名的运用: 函数名是一个变量,但他是一个特殊变量,加上括号可以执行函数. ⼆. 闭包什么是 ...
- C语言运算符(注意事项)
1.C语言取余注意事项:% a.求余.模运算符(%)时要求两数必须是整型数据. b.取余的结果,是取决于被除数 (不管除数是正数 还是 负数,模的符号与被除数的符号相同). 例:8÷2=4 ...
- 第一周 Introduction
欢迎 欢迎来到这门关于机器学习的免费网络课程,机器学习是近年来最激动人心的技术之一,在这门课中,你不仅可以了解机器学习的原理,更有机会进行实践操作,并且亲自运用所学的算法. 每天你都可能在不知不觉中使 ...
- Python 把两个列表遍历为一个
两个list, 有对应关系,希望同时完成遍历 用迭代器迭代的方法也不是不可以,python提供了更直观的方法: 可以使用zip把两个list打包 , 类似: list1 = [1,2,3,4] lis ...
- 简易cmake多文件多目录工程模板
今天心血来潮,想在服务器上试试写libevent的工程是什么感受,那第一步就是学会怎么用cmake建工程,之前也没接触过cmake,然后一上午,比较懵逼,下午看实验室哥们给的一个教程,然后,慢慢理解C ...
- HDU 4745 Two Rabbits(最长回文子序列)(2013 ACM/ICPC Asia Regional Hangzhou Online)
Description Long long ago, there lived two rabbits Tom and Jerry in the forest. On a sunny afternoon ...
- PhpStorm 配置IDE
IDE => Xdebug => Apache(XAMPP) => Firefox + easist Xdebug 1>XAMPP停止apache服务;2>在安装目录下找 ...
- cygwin上编译RPC框架thrift
cygwin的配置就不多说了,缺什么就通过安装器安装好了. 在thrift的官网下载 thrift-0.11.0源码,通过cmake编译,生成Makefile之后,make出现编译错误 /cygdri ...
- poj3026(bfs+prim)最小生成树
The Borg is an immensely powerful race of enhanced humanoids from the delta quadrant of the galaxy. ...
- Jlink 软件断点和硬件断点
调试2440 RAM拷贝至SDRAM遇到的问题 汇编代码主要是初始化一些寄存器,关狗,初始化时钟,初始化存储管理器以便访问内存,然后将SoC上4k RAM数据拷贝至SDRAM,然后在SRAM里面运行, ...