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. Kruskal HDOJ 1233 还是畅通工程

    题目传送门 /* 最小生成树之kruskal算法--并查集(数据结构)实现 建立一个结构体,记录两点和它们的距离,依照距离升序排序 不连通就累加距离,即为最小生成树的长度 */ #include &l ...

  2. 学习JavaScript数据结构与算法 (一)

    学习JavaScript数据结构与算法 的笔记, 包含一二三章 01基础 循环 斐波那契数列 var fibonaci = [1,1] for (var i = 2; i< 20;i++) { ...

  3. vue文件中style标签的几个标识符

    .vue文件中style标签的几个标识符 在人生就要绝望的时候, 被编辑器所提示的一个scopedSlots所拯救. 卧槽, 写到最后才发现这个属性的具体卵用. 详情见最后解决办法. 问题背景 问题由 ...

  4. matplotlib 绘图实例01:正弦余弦曲线

    该讲的实例结果如下图所示: 第01步:导入模块,并设置显示中文和负号的属性: import matplotlib.pyplot as plt import numpy as np plt.rcPara ...

  5. Windows下DVWA安装指南

    注意:DVWA需要依赖httpd.PHP.MySQL.php-mysql等应用或组件,最简单的方法是安装wampserver(http://www.wampserver.com/),安装完了所需的各种 ...

  6. “玲珑杯”ACM比赛 Round #5 H -- Variance 简单树状数组

    可以把每个公式都化简,然后得到要维护的东西就是平方和,和前缀和,两个bit即可 不能cin,超时.IOS后都不行. scanf用lld #include <cstdio> #include ...

  7. python_函数进阶(5)

    第1章 函数有用信息1.1 login.__doc__1.2 login.__name__第2章 装饰器的进阶2.1 带参数的装饰器2.2 多个装饰器装饰一个函数2.3 开放封闭原则 第3章 可迭代对 ...

  8. CentOS 6.9:MySQL Daemon failed to start.

    [root@Server_1 12:02:58 ~ 25]#service mysqld start MySQL Daemon failed to start.Starting mysqld: [ro ...

  9. 013、BOM对象的应用

    BOM结构图如下: DOM结构图如下: BOM和DOM BOM,Bowser Object Model浏览器对象模型.提供了访问和操作浏览器各组件的途径或方法. 比如:Navigator对象:浏览器的 ...

  10. android studio 定时器操作 实现定时执行相关任务

    package ipget.wenzheng.studio.ipget; import android.os.Bundle; import android.os.Handler; import and ...