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;
}

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

最新文章

  1. 用CSS绘制箭头等三角形图案 [译]
  2. Shell命令_case
  3. IE6、IE7、IE8的CSS、JS兼容
  4. wampserver 绑定域名 外部可以正常访问
  5. Linux查看用户和组命令
  6. javascript对象深拷贝,浅拷贝 ,支持数组
  7. [国嵌笔记][024][ARM汇编编程概述]
  8. 芝麻软件: Python爬虫进阶之爬虫框架概述
  9. 解决只读时ios下input光标问题
  10. gulp项目和webpack项目在浏览器中查看的方式
  11. nginx 配置白名单
  12. vue源码的构建
  13. azkaban disable 停用部分工作流
  14. 从零开始学Kotlin-类的继承(6)
  15. Entity Framework 与 LINQ to SQL
  16. SSH框架整合思想
  17. Educational Codeforces Round 61 (Rated for Div. 2) E. Knapsack
  18. map和object互相转换
  19. 通读cheerio API-网络爬虫
  20. Centos7最小化安装之工作站设置

热门文章

  1. ISBN和标准编码关系以及概念
  2. C# winform combobox控件中子项加删除按钮(原创)
  3. android 利用TrafficStats类获取本应用的流量
  4. Asp.net Form登陆认证的回顾学习
  5. 解决 MVC 用户上线下线状态问题
  6. python使用简单http协议来传送文件
  7. sizeclass
  8. eval和new Function的区别
  9. instanceof、==号、Objetc类
  10. .Net码农学Android---小点整理