首页 > 其他分享 >ZOJ 3203 Light Bulb

ZOJ 3203 Light Bulb

时间:2022-10-18 15:07:25浏览次数:38  
标签:his 3203 house Light ZOJ double bulb include he

Compared to wildleopard's wealthiness, his brother mildleopard is rather poor. His house is narrow and he has only one light bulb in his house. Every night, he is wandering in his incommodious house, thinking of how to earn more money. One day, he found that the length of his shadow was changing from time to time while walking between the light bulb and the wall of his house. A sudden thought ran through his mind and he wanted to know the maximum length of his shadow.

Input

The first line of the input contains an integer T (T <= 100), indicating the number of cases.

Each test case contains three real numbers Hh and D in one line. H is the height of the light bulb while h is the height of mildleopard. D is distance between the light bulb and the wall. All numbers are in range from 10-2 to 103, both inclusive, and H - h >= 10-2.

Output

For each test case, output the maximum length of mildleopard's shadow in one line, accurate up to three decimal places..

Sample Input

3
2 1 0.5
2 0.5 3
4 3 4

Sample Output

1.000
0.750
4.000
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <stdio.h>

using namespace std;
double h,H,d;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%lf%lf%lf",&H,&h,&d);
double x=sqrt((H-h)*d);
double x2=d*h/H;
double l=(H-h)*d/H;
double ans;
if(x>l&&x<d)
ans=H+d-(2*(sqrt((H-h)*d)));
else
ans=max(x2,h);
printf("%.3f\n",ans);

}
return 0;
}



标签:his,3203,house,Light,ZOJ,double,bulb,include,he
From: https://blog.51cto.com/u_15834522/5766673

相关文章

  • ZOJ 3927 Programming Ability Test
    ProgrammingAbilityTest(PAT)aimstoevaluateobjectively,throughunifiedexaminationswithautomaticonlinejudgingsystem,theabilitiesoftesteesinprog......
  • ZOJ 3935 2016
    Inmathematics,apolygonalnumberisanumberrepresentedasdotsorpebblesarrangedintheshapeofaregularpolygon.Thedotsarethoughtofasalphas(uni......
  • TiDB Lightning导入超大型txt文件实践
    背景TiDB提供了很多种数据迁移的方式,但这些工具/方案普遍对MySQL比较友好,一旦涉及到异构数据迁移,就不得不另寻出路,借助各种开源或商业的数据同步工具。其实数据在不同系......
  • 实验4:开源控制器实践——OpenDaylight
    基本要求1.利用Mininet平台搭建下图所示网络拓扑,并连接OpenDaylight控制器;2.通过Postman工具调用OpenDaylight提供的API下发流表,实现拓扑内主机h1和h3网络中断10s。进......
  • 实验4:开源控制器实践——OpenDaylight
    实验4:开源控制器实践——OpenDaylight一、实验目的能够独立完成OpenDaylight控制器的安装配置;能够使用Postman工具调用OpenDaylightAPI接口下发流表。二、实验环境......
  • 实验4:开源控制器实践——OpenDaylight
    一、实验目的能够独立完成OpenDaylight控制器的安装配置;能够使用Postman工具调用OpenDaylightAPI接口下发流表。二、实验环境Ubuntu20.04Desktopamd64三、实验要......
  • 实验4:开源控制器实践——OpenDaylight
    (一)基本要求利用Mininet平台搭建下图所示网络拓扑,并连接OpenDaylight控制器;通过Postman工具调用OpenDaylight提供的API下发流表,实现拓扑内主机h1和h3网络中断10s。(二)进......
  • 实验4:开源控制器实践——OpenDaylight
    实验4:开源控制器实践——OpenDaylight一、实验目的能够独立完成OpenDaylight控制器的安装配置;能够使用Postman工具调用OpenDaylightAPI接口下发流表。二、实验环境Ubu......
  • 实验4:开源控制器实践——OpenDaylight
    实验4:开源控制器实践——OpenDaylight一、实验目的能够独立完成OpenDaylight控制器的安装配置;能够使用Postman工具调用OpenDaylightAPI接口下发流表。二、实验环境Ub......
  • 实验4:开源控制器实践——OpenDaylight
    实验4:开源控制器实践——OpenDaylight一、实验目的1.能够独立完成OpenDaylight控制器的安装配置;2.能够使用Postman工具调用OpenDaylightAPI接口下发流表。二、实验环......