博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UVa 10566 - Crossed Ladders 【二分】
阅读量:5922 次
发布时间:2019-06-19

本文共 1547 字,大约阅读时间需要 5 分钟。

 
Time Limit:2000MS     
Memory Limit:
32768KB     
64bit IO Format:
%lld & %lluDescription

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


列出方程组, 利用二分求解精确值。

#include
#include
#include
using namespace std;double x, y, c;double ans(double z) { return 1 - c/sqrt(x*x - z*z) - c/sqrt(y*y - z*z);}int main() { int t; scanf("%d", &t); int cnt = 0; while(t--){ scanf("%lf%lf%lf",&x, &y, &c); double l = 0, mid, r = min(x, y); while(r - l > 1e-8) { mid = (l + r)/2; if(ans(mid) > 0) l = mid; else r = mid; } printf("Case %d: %.8lf\n", ++cnt, mid); } return 0;}

 

转载于:https://www.cnblogs.com/cniwoq/p/6770902.html

你可能感兴趣的文章
两个数的交换
查看>>
jQuery一篇全解
查看>>
javaweb学习总结(四十三)——Filter高级开发
查看>>
k8s pod和容器概念的区分
查看>>
OC高效率52之不要使用dispatch_get_current_queue
查看>>
docker中安装了rabbitmq后无法连接
查看>>
linux 的目录总结
查看>>
odoo基础2
查看>>
ARM cortex a 的SDRAM (DDR)
查看>>
利用单臂路由实现VLAN间路由
查看>>
zabbix server服务安装与配置详情
查看>>
动态代理
查看>>
《Inside C#》笔记(二) 初识C#
查看>>
hibernate的校验框架validation 和 HttpMessageConverter的配置方式
查看>>
动态链接库管理
查看>>
尼日利亚国内最大航空公司Arik Air遭遇数据泄露
查看>>
if (log.isDebugEnabled()) 使用场景
查看>>
2019年首批!网易易盾加固系统通过中国反网络病毒联盟认证
查看>>
Hadoop集群环境搭建
查看>>
Quartz2D
查看>>