第 2326 题  : 
(时间限制为:1000毫秒)

Description
A narrow street is lined with tall buildings. An x foot long ladder is rested at the base of the building on the right side of the street and leans on the building on the left side. A y foot long ladder is rested at the base of the building on the left side of the street and leans on the building on the right side. The point where the two ladders cross is exactly c feet from the ground. How wide is the street?
Input
Each line of input contains three positive floating point numbers giving the values of x, y, and c.
Output
For each line of input, output one line with a floating point number giving the width of the street in feet, with three decimal digits in the fraction.
Sample Input
30 40 10
12.619429 8.163332 3
10 10 3
10 10 1
Sample Output
26.033
7.000
8.000
9.798
#include<iostream> #include<cmath> using namespace std; double x,y,c,w,now,temp,a,b; double ff(double f) { return pow(f,4)-2*c*pow(f,3)+w*pow(f,2)-2*w*c*f+w*pow(c,2); } int main() { while(cin>>x>>y>>c) { w=x*x-y*y; a=y; b=c; now=(a+b)/2; temp=ff(now); while(fabs(temp)>0.000001) { if(temp>0) { a=now; } else { b=now; } now=(a+b)/2; temp=ff(now); } printf("%.3f/n",sqrt(y*y-now*now)); } return 0; }

Crossed ladders相关推荐

  1. POJ2507 Crossed ladders

    POJ2507 Crossed ladders 本题复习实数域上的二分. 实数域上的二分与普通的二分不同,它需要设置一个精度,据题目而定(一般不会小于1e-9). 本题首先推公式,由相似三角形其实可以 ...

  2. 计算几何(二分) - Crossed Ladders - UVA 10566

    计算几何(二分) - Crossed Ladders - UVA 10566 题意: 如上图,给定三个浮点数x,y,c,计算两个房子之间的间距.如上图,给定三个浮点数x,y,c,计算两个房子之间的间距 ...

  3. Crossed Ladders 计算几何

    高中几何题 A narrow street is lined with tall buildings. An x foot long ladder is rested at the base of t ...

  4. UVA10566 Crossed Ladders(计算几何+二分)

    有两把梯子搭在墙上,给出这两把梯子的长度 x,y,以及他们的交点,交点的高度为 h,求这两个房屋之间的距离 如上图所示,易证红色内有两个三角形相似和绿色内有两个三角形相似 所以有: double x, ...

  5. 【Uva10566】Crossed Ladders

    列出一个包含x,y,c的关系式,设宽为w,底边垂线左边为a,根据相似三角形关系: 1.a/w=c/sqrt(y*y-w*w); 2.(w-a)/w=c/sqrt(y*y-w*w); 两式合并消去a得: ...

  6. Lightoj 1062 Crossed Ladders (二分)

    题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1062 题意:两根棍子斜放在墙上,给你棍子的长度和他们交点距离地面的高度 ,求两 ...

  7. UVa 10566 - Crossed Ladders

    设宽度为w,二分w. 1 #include <cstdio> 2 #include <cmath> 3 #include <algorithm> 4 5 #defi ...

  8. 2012 winter training @HIT Day 2 解题报告

    今天第二天,主要练习二分和枚举.其实我突然发现,当做题突然卡主的时候,不妨想想今天练习的是什么内容-- 传送门http://acm.hit.edu.cn/hoj/contest/view?id=100 ...

  9. 【源码】数学研究者的Cleve_s实验室

    主要内容包括: Explorations: constant_width Maze generation @vfp16 Mandelbrot Set Runge Phenomenon Fourier ...

最新文章

  1. leetcode Edit Distance
  2. tcpdump 命令的个常用选项:三
  3. 一个不错的windows编程网址
  4. java基础:13.2 集合框架 - LinkedList、Queue
  5. 只显示 前100个字 java 实现截取字符串!使用! c:if test=${fn:length(onebeans.info)100 }${ fn:substri...
  6. 42. 添加 Expires 头(3)
  7. 如何下载spring源码?
  8. Python >>> 基于UDP 协议的实时网络视频传输
  9. 计算机机械制图试题及答案,机械制图习题集-附带答案
  10. IBM服务器管理口IMM使用指南
  11. matlab单位函数定义,MATLAB 函数(一)
  12. cmd命令netstat -ano不是内部命令解决方案
  13. 开发者成长激励计划-基于TencentOS Tiny FDM 3D打印机云控制系统方案
  14. Crowding Counter 之 根据.mat标注制作密度图进行训练
  15. 【工作】引用文献(医学文献注意事项)
  16. 升级笔记本硬件并安装Debian的过程
  17. 五、VR视频播放器开发 ---- Android VR视频/Google VR for Android /VR Pano/VR Video
  18. 【简单】LCP 02. 分式化简
  19. JavaWeb核心|EL表达式JSTLFilterListener
  20. OUC2022秋季软件工程第一周作业

热门文章

  1. selenium等待时间处理
  2. LeetCode 700题 题解答案集合 Python
  3. 多个硬盘间克隆操作系统
  4. 2021年安徽省大数据与人工智能竞赛人工智能现场赛2和3题
  5. 玩转MySQL:都2022年了,这些数据库技术你都知道吗
  6. 关于ContentProviderContentResolver的学习与使用
  7. ACPI相关(5)- PCI热插拔(三)
  8. 计算机无法转换输入发,电脑输入法切换不了怎么办 输入法怎么设置快捷键图文教程...
  9. 继电器的常开常闭状态
  10. C语言经典例28-利用递归算年龄