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. 【SpringCloud】第二篇: 服务消费者(rest+ribbon)

    前言: 必需学会SpringBoot基础知识 简介: spring cloud 为开发人员提供了快速构建分布式系统的一些工具,包括配置管理.服务发现.断路器.路由.微代理.事件总线.全局锁.决策竞选. ...

  2. mysql数据库----Pymysql

    本节重点: pymysql下载和使用 sql注入 增.删.改:conn.commit() 查:fetchone.fetchmany.fetchall 一.pymysql的下载和使用 之前我们都是通过M ...

  3. 孤荷凌寒自学python第七十四天开始写Python的第一个爬虫4

    孤荷凌寒自学python第七十四天开始写Python的第一个爬虫4 (完整学习过程屏幕记录视频地址在文末) 今天在上一天的基础上继续完成对我的第一个代码程序的书写. 直接上代码.详细过程见文末屏幕录像 ...

  4. Android之Audio和Video

    The Android platform offers built-in encoding/decoding for a variety of common media types, so that ...

  5. php+Mysql中网页出现乱码的解决办法详解

    $conn = mysql_connect("$host","$user","$password");mysql_query("S ...

  6. Mybatis学习系列(七)缓存机制

    Mybatis缓存介绍 MyBatis提供一级缓存和二级缓存机制. 一级缓存是Sqlsession级别的缓存,Sqlsession类的实例对象中有一个hashmap用于缓存数据.不同的Sqlsessi ...

  7. storm-kafka版本不匹配的问题

    storm集群是1.0.0版本,kafka的集群版本是0.10.0,所以想当然的使用了kafka_2.10-0.10.0.1.jar作为storm-kafka-1.0.0.jar的依赖使用, 没想到导 ...

  8. qemu的device参数解释 包括socket的一些知识

    前面一片是driver,是把这个新的设备“插入到虚机中”,device 是准备驱动了.device 都是和设备配合使用的.要怎么去驱动一个设备,包括使用的驱动函数是啥,device后面的函数根据驱动的 ...

  9. Maven中mirrors和repository的关系

    一.前言 之前没有搞清楚pom.xml里面配置的repositorys节点配置的仓库和mirrors里面配置的仓库的“镜像”间的关系,特意去搜索了相关内容,这边有篇文章讲得透彻,所以这边转载一下~ 二 ...

  10. sqoop工具从oracle导入数据2

    sqoop工具从oracle导入数据 sqoop工具是hadoop下连接关系型数据库和Hadoop的桥梁,支持关系型数据库和hive.hdfs,hbase之间数据的相互导入,可以使用全表导入和增量导入 ...