1062 - Crossed Ladders
Time Limit: 2 second(s) Memory Limit: 32 MB

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

Input starts with an integer T (≤ 10), denoting the number of test cases.

Each test case contains three positive floating point numbers giving the values of xy, and c.

Output

For each case, output the case number and the width of the street in feet. Errors less than 10-6 will be ignored.

Sample Input

Output for Sample Input

4

30 40 10

12.619429 8.163332 3

10 10 3

10 10 1

Case 1: 26.0328775442

Case 2: 6.99999923

Case 3: 8

Case 4: 9.797958971

大意:求底的长度;

找关系:设x与左边楼的交点为A,与右边楼的交点为C,y与左边楼的交点为B,与右边楼的交点为D;x与y的交点为E,由E向地面做垂线,设垂足为F。由三角形相似:EF/AB=CF/CB=1-(BF/BC)=1-(EF/CD),也就是EF/AB=1-(EF/CD),两边同时除以EF

注意:输出精度

#include<stdio.h>
#include<math.h>
#define eps 1e-9
#define min(a,b) ((a)<(b)?(a):(b))
int main(){
int t;
double a,b,c,high,low,mid;
scanf("%d",&t);
// cout<<min(t,a);
for(int i=1;i<=t;i++){
scanf("%lf%lf%lf",&a,&b,&c);
high=min(a,b);
low=0; while(high-low>eps){
mid=(high+low)/2;
if((1/sqrt(a*a-mid*mid)+1/sqrt(b*b-mid*mid))>1/c) //说明mid偏大
high=mid;
else low=mid;
}
printf("Case %d: %.8lf\n",i,mid);
}
return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

二分---LIGHTOJ 1062的更多相关文章

  1. LightOJ 1062 - Crossed Ladders 基础计算几何

    http://www.lightoj.com/volume_showproblem.php?problem=1062 题意:问两条平行边间的距离,给出从同一水平面出发的两条相交线段长,及它们交点到水平 ...

  2. 二分--LIGHTOJ 1088查找区间(水题)

    #include <iostream> #include <cstdio> #include <cmath> using namespace std; const ...

  3. LightOj 1138 - Trailing Zeroes (III) 阶乘末尾0的个数 & 二分

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1138 题意:给你一个数n,然后找个一个最小的数x,使得x!的末尾有n个0:如果没有输出 ...

  4. lightOJ 1132 Summing up Powers(矩阵 二分)

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1132 题意:给出n和m.求sum(i^m)%2^32.(1<=i<=n) ...

  5. LightOJ 1138 Trailing Zeroes (III)(二分 + 思维)

    http://lightoj.com/volume_showproblem.php?problem=1138 Trailing Zeroes (III) Time Limit:2000MS     M ...

  6. LightOJ 1088 - Points in Segments 二分

    http://www.lightoj.com/volume_showproblem.php?problem=1088 题意:给出N个点,Q个查询,问在区间内的点数有多少个. 思路:直接在线二分,注意边 ...

  7. LightOj 1088 - Points in Segments (二分枚举)

    题目链接: http://www.lightoj.com/volume_showproblem.php?problem=1088 题目描述: 给出一个n位数升序排列的数列,然后q个查询,每个查询问指定 ...

  8. lightoj 1138 - Trailing Zeroes (III)【二分】

    题目链接:http://lightoj.com/volume_showproblem.php? problem=1138 题意:问 N. 末尾 0 的个数为 Q 个的数是什么? 解法:二分枚举N,由于 ...

  9. Lightoj 1235 - Coin Change (IV) 【二分】

    题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1235 题意: 有N个硬币(N<=18).问是否能在每一个硬币使用不超过两 ...

随机推荐

  1. SQL SERVER 2008 R2 还原数据库3154错误

    1.SQL SERVER 2008 在还原数据库时,会报错. 提示错误:"备份集中的数据库备份与现有的 '***' 数据库不同.RESTORE DATABASE 正在异常终止. (Micro ...

  2. android 的通知管理

    1在context里定义通知管理器(NotificationManager) NotificationManager notificationManager = (NotificationManage ...

  3. PHP生成随机字符串包括大小写字母

    PHP生成随机字符串包括大小写字母,这里介绍两种方法: 第一种:利用字符串函数操作 <?php /** *@blog <www.phpddt.com> */ function cre ...

  4. linux中PHP dirname(__FILE__)路径问题解决

    近期在给wordpress开发模板功能时发现,直接使用include(“文件名”)的形式调用其他php代码片段时会出现路径错误.之前服务器环境一直都是iis,未曾出现过类似的BUG,但换成linux服 ...

  5. 极路由1s手工安装ss插件

    1.极路由申请开放root权限,将会失去保修,不过100块的东西还保修个什么 2.用putty连接极路由注意端口号 3. 然后一段一段执行下面的代码,很简单,复制一个段落的代码,粘贴进去,回车执行. ...

  6. PowerShell 方式部署Sharepoint Solution

    覆盖 Uninstall-SPSolution –Identity Caesarstone.GlobalSite.WebSite.wsp –WebApplication http://myserver ...

  7. delphi 基础之二 面向对象概念初步

    面向对象概念初步 •类自动生成 快捷键:ctrl+shift+c 1.类的定义 类是用户创建的数据类型,包括状态.表达式和一些操作.有3个组成部分,即字段.方法和属性.字段是类的内部数据变量,方法就是 ...

  8. Oracle存储过程学习备忘

    之前的项目使用存储过程很少,但在实际的项目中,存储过程的使用是必不可少的. 存储过程是一组为了完成特定功能的SQL 语句 集,经编译后存储在数据库中:存储过程创建后,一次编译在程序中可以多次调用,对安 ...

  9. 第三节:卸载AppDomain

    AppDomain很出色的一个能力就是它允许卸载.卸载AppDomain会导致CLR卸载AppDomain中的所有程序集.还会释放AppDomain的Loader堆.为了卸载一个AppDomain,可 ...

  10. MAC 重置MySQL root 密码

    重置MySQL root 密码:当忘记密码,或者想要强行重置 MySQL 密码的时候,可以像下面这样: 1.停止 MySQL 服务 sudo /usr/local/mysql/support-file ...