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

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

4

30 40 10

12.619429 8.163332 3

10 10 3

10 10 1

Sample Output

Case 1: 26.0328775442

Case 2: 6.99999923

Case 3: 8

Case 4: 9.797958971

纯数学题,

设宽度为w,交点距左楼距离为a,

 #include<cstdio>
#include<cmath>
#include <algorithm>
using namespace std;
double x,y,c;
double f(double a)
{
return (-c/sqrt(x*x-a*a)-c/sqrt(y*y-a*a));
}
int main()
{
double l,r,mid;
int t;
int num=;
scanf("%d",&t);
while(t--)
{ scanf("%lf %lf %lf",&x,&y,&c);
l=;
r=min(x,y);
while(r-l > 1e-)
{
mid=(l+r)/2.0;
if(f(mid) > )
{
l=mid;
}
else
{
r=mid;
}
}
printf("Case %d: ",++num);
printf("%.7lf\n",l); }
}

Crossed Ladders 求街道宽度 (二分法)的更多相关文章

  1. Gym - 101635K:Blowing Candles (简单旋转卡壳,求凸包宽度)

    题意:给定N个点,用矩形将所有点覆盖,要求矩形宽度最小. 思路:裸体,旋转卡壳去rotate即可. 最远距离是点到点:宽度是点到边. #include<bits/stdc++.h> #de ...

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

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

  3. uva 10566 Crossed Ladders (二分)

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...

  4. POJ 2185 Milking Grid (KMP,求最小覆盖子矩阵,好题)

    题意:给出一个大矩阵,求最小覆盖矩阵,大矩阵可由这个小矩阵拼成.(就如同拼磁砖,允许最后有残缺) 正确解法的参考链接:http://poj.org/showmessage?message_id=153 ...

  5. 二分---LIGHTOJ 1062

    1062 - Crossed Ladders PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB A ...

  6. HOJ题目分类

    各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ...

  7. lightoj刷题日记

    提高自己的实力, 也为了证明, 开始板刷lightoj,每天题量>=1: 题目的类型会在这边说明,具体见分页博客: SUM=54; 1000 Greetings from LightOJ [简单 ...

  8. sicily 题目分类

    为了方便刷题,直接把分类保存下来方便来找. 转自:http://dengbaoleng.iteye.com/blog/1505083 [数据结构/图论] 1310Right-HeavyTree笛卡尔树 ...

  9. SVM – 线性分类器

    感知机 要理解svm,首先要先讲一下感知机(Perceptron),感知机是线性分类器,他的目标就是通过寻找超平面实现对样本的分类:对于二维世界,就是找到一条线,三维世界就是找到一个面,多维世界就是要 ...

随机推荐

  1. Cloudera Manager是啥?主要是干啥的?

    简单来说,Cloudera Manager是一个拥有集群自动化安装.中心化管理.集群监控.报警功能的一个工具(软件),使得安装集群从几天的时间缩短在几个小时内,运维人员从数十人降低到几人以内,极大的提 ...

  2. iOS 上传的图片在HTML上显示时,图片方向信息(EXIF Orientation)异常

    将iPhone 6s拍摄的照片上传到服务器之后, 在Web网页上看到图片被逆时针旋转了90度, 这让我很惆怅呐! 出现这个问题其实是因为上传的图片为.jpg格式,.jpg文件含有EXIF信息, 其中E ...

  3. python中时间日期格式化符号的含义

    %y   两位数的年份表示(00-99) %Y 四位数的年份表示(000-9999) %m 月份(01-12) %d 月内中的一天(0-31) %H    24小时制小时数(0-23) %I   12 ...

  4. 洛谷 P3960 列队

    https://www.luogu.org/problemnew/show/P3960 常数超大的treap #pragma GCC optimize("Ofast") #incl ...

  5. Win10 Hyper-v 中安装 CentOS 搭建开发环境

    Windows 环境 操作系统:Windows 10 开发环境:VS2005(需启动.NET Framework 3.5 ,才能正常安装使用)  Linux 环境 发行版:CentOS 7_x64 安 ...

  6. 通用mapper的generator

    <plugin> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-genera ...

  7. P1309 瑞士轮 未完成 60

    题目背景 在双人对决的竞技性比赛,如乒乓球.羽毛球.国际象棋中,最常见的赛制是淘汰赛和循环赛.前者的特点是比赛场数少,每场都紧张刺激,但偶然性较高.后者的特点是较为公平,偶然性较低,但比赛过程往往十分 ...

  8. 在phpnow中配置phpunit

    前面都好了之后,在 D:\phpnow\php-5.2.14-Win32\PEAR 之外的地方执行 phpinfo 都会出现以下错误 Warning: require_once(File/Iterat ...

  9. 工作中Docker使用命令笔记

    docker安装与启动 安装docker [root@localhost /]# yum -y install docker-io 更改配置文件 [root@localhost /]# vi /etc ...

  10. vue项目中常用的一些公共方法

    //校验手机号码 export function isSpecialPhone(num) { return /^1[2,3,4,5,7,8]\d{9}$/.test(num) } //校验中英文姓名 ...