poj 1905 Expanding Rods(木杆的膨胀)【数学计算+二分枚举】
Time Limit: 1000MS | Memory Limit: 30000K | |
Total Submissions: 13516 | Accepted: 3484 |
Description

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.
Input
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.
Output
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
Sample Output
61.329
225.020
0.000 题目:可以这样理解,给你一根木杆,夹在某物体之间。现在木杆会受热膨胀,膨胀增长,在两端物体的挤压下就会变弯曲,如上图所示。
从一根直的木杆变到弯曲的木杆,两种状态下,木杆中间位置的高度差是多少?
解法全在上面的图片中! 代码:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <iostream>
#include <string>
#include <stack>
#include <algorithm>
#define eps 1e-5 using namespace std; int main()
{
// L'=(1+n*C)*L
double L, n, c;
while(scanf("%lf %lf %lf", &L, &n, &c)!=EOF)
{
if(L<0 && n<0 && c<0) break;
double low=0.0;
double high=0.5*L;
double mid;
double s=(1.0+n*c)*L;
double R; while(high-low>eps){
mid=(low+high)/2.0;
R = (4*mid*mid+L*L)/(8*mid);//化简成一次除法 减小精度误差
if(2*R*asin(L/(2*R)) < s)
low=mid;
else
high=mid;
}
printf("%.3lf\n",mid);
}
return 0;
}
poj 1905 Expanding Rods(木杆的膨胀)【数学计算+二分枚举】的更多相关文章
- POJ 1905 Expanding Rods
Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 1 ...
- POJ 1905 Expanding Rods(二分)
Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 20224 Accepted: 5412 Descr ...
- 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(二分+计算几何)
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( 二分搜索 )
题意:一个钢棍在两面墙之间,它受热会膨胀成一个圆弧形物体,这个物体长 S = ( 1 + n * C ) * L,现在给出原长 L ,温度改变量 n ,和热膨胀系数 C,求膨胀后先后中点的高度差. 思 ...
- poj 1905 Expanding Rods (数学 计算方法 二分)
题目链接 题意:将长度为L的棒子卡在墙壁之间.现在因为某种原因,木棒变长了,因为还在墙壁之间,所以弯成了一个弧度,现在求的是弧的最高处与木棒原先的地方的最大距离. 分析: 下面的分析是网上别人的分析: ...
- poj 1905 Expanding Rods 二分
/** 题解晚上写 **/ #include <iostream> #include <math.h> #include <algorithm> #include ...
随机推荐
- Unity3D学习笔记——UIScrollBar和UIScrollView使用
UIScrollBar和UIScrollView结合使用效果图如下: 一:使用步骤 1.创建一个UIScrollView 2.然后创建一个UIScrollBar 3.打开UIScrollView ...
- es6 async与await实战
在使用js的时候,我们经常会遇到一个问题,就是我们需要等待请求返回再做下一步处理,之前的处理方式是通过ajax的success或者callback之类的方法,不过一层一层真的恶心,而且只是针对单个页面 ...
- WebApi~通过HttpClient来调用Web Api接口
异步请求 ///<summary> /// HttpClient实现Post请求(异步) /// </summary> static async void dooPost() ...
- UIAlertController custom font, size, color
本文转载至 http://stackoverflow.com/questions/26460706/uialertcontroller-custom-font-size-color up vote2d ...
- Handler classes should be static or leaks might occur
http://droidyue.com/blog/2014/12/28/in-android-handler-classes-should-be-static-or-leaks-might-occur ...
- NodeJS版本EasyDarwin开源流媒体服务器开发心得
title: Node版本EasyDarwin开发心得 date: 2018-03-27 22:46:15 tags: 年后着手Node版本EasyDarwin的开发工作,截止到今天2018年03月2 ...
- Java多线程的两种实现方式
Java总共有两种方式实现多线程 方式1:通过继承Thread类的方式 package com.day04; /** * 通过继承Thread类并复写run方法来是实现多线程 * * @author ...
- 对django模型中的objects的理解
object是模型属性,用于模型对象和数据库交互. object=Manager()是管理器类型的对象,是model和数据库进行查询的接口 可以自定义管理对象 books=models.Manager ...
- ubuntu1.4搭建zookeeper3.5.2分布式集群
1.下载 官网链接:http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper-3.5.2-alpha/zookeeper-3.5.2-alpha.ta ...
- Python菜鸟之路:Django 表单验证
前言 Django中完成表单验证,常用的有两种方法: 一种是通过HTML + JS + Ajax实现. 另一种是通过Django自身的forms模块来生成相应个HTML标签来完成表单验证.这是本节着重 ...