A. Light Bulb
A. Light Bulb
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 H, h 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 解题:好吧,比较喜欢数学解法,速度快嘛。。。参阅某神的代码。。。
算法:利用函数的凸性
思路一:
学妹的思路:三分 L
#include<stdio.h>
#include<string.h>
#include<math.h> int main()
{
int T;
double H,h,D;
scanf("%d", &T);
while(T--)
{
scanf("%lf%lf%lf", &H,&h,&D);
double x1 = (H-h)*D/H;
double x2 = D;
double x0 = sqrt(D*(H-h)); double x; if(x1 <= x0 && x0 <= x2) x = x0;
else if(x0 <= x1) x = x1;
else if(x0 >= x2) x = x2; double ans = D+H- (x + (H-h)*D/x);
printf("%.3lf\n", ans);
}
return ;
}
A. Light Bulb的更多相关文章
- 三分 --- ZOJ 3203 Light Bulb
Light Bulb Problem's Link: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3203 Mean: ...
- Light Bulb(三分)
ZOJ Problem Set - 3203 Light Bulb Time Limit: 1 Second Memory Limit: 32768 KB Compared to wildl ...
- ZOJ 3203 Light Bulb - 求导求最大值
如果L全在地面上: 输出 h * D / H 如果L全在墙上: 输出 h 否则: (D - X ) / X = Y / (H - h) L = D - X + h - Y 然后对L求导即可 #incl ...
- zoj 3203 Light Bulb,三分之二的基本问题
Light Bulb Time Limit: 1 Second Memory Limit: 32768 KB Compared to wildleopard's wealthiness, h ...
- ZOJ 3203 Light Bulb (三分+计算几何)
B - Light Bulb Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submit ...
- ZOJ 3203 Light Bulb (三分查找)
Light Bulb Time Limit: 1 Second Memory Limit: 32768 KB Compared to wildleopard's wealthiness, h ...
- ZOJ 3203 Light Bulb
Compared to wildleopard's wealthiness, his brother mildleopard is rather poor. His house is narrow a ...
- ZOJ 3203 Light Bulb(数学对勾函数)
Light Bulb Time Limit: 1 Second Memory Limit: 32768 KB Compared to wildleopard's wealthiness, h ...
- TOJ 2814 Light Bulb
Description Compared to wildleopard's wealthiness, his brother mildleopard is rather poor. His house ...
随机推荐
- Less的学习和使用
官网 http://less.bootcss.com/usage/ 在线编译器 http://tool.oschina.net/less
- babel-loader7和babel8版本的问题
根据官网https://www.npmjs.com/package/babel-loader要对应版本 一.babel7.X版本 1.要安装的包 第1套包:npm i babel-core babe ...
- 深刻的理解Fragment生命周期 都在做什么,fragment生命周期
先上一个生命周期的图片吧 下面挨个的说一下我平时 都怎么使用 这些 回调函数的 流程: onAttach() 作用:fragment已经关联到activity, 这个是 回调函数 @Override ...
- win10下vs2013为程序集新建强名称文件时“未能完成操作。拒绝访问”的解决方案
昨日,在使用vs2013开发开发一个小工具,打算给这个小工具的源代码进行保护. 在输入完成建立强名称密钥文件时,爆出了如下错误: 一开始以为是项目所在路径的权限问题,于是给项目所在路径文件夹添加了“U ...
- vs2010调试sql2008存储过程
1.安装vs2010sp1补丁 2.vs中打开服务器资源管理器,并进行数据库连接,连接时要注意 3. 4.可以打开数据库中的存储过程进行调试了
- GP SQL 优化
1.收集统计信息vacuum full analyze ZCXT.ZCOT_PS_PROJECT; 2.检查表的数据量分布select gp_segment_id,count(*) from fact ...
- (五)maven之外置maven
eclipse外置maven eclipse内置的maven插件是固定版本,如果要用其他版本的maven,可以使用外置maven. ① 在菜单栏上点击“Windows”à“Preferences ...
- vue 动态合并单元格、并添加小计合计功能
1.效果图 2.后台返回数据格式(平铺式) 3.后台返回数据后,整理所需要展示的属性存储到(items)数组内 var obj = { "id": curItems[i].id, ...
- 【转】Python 访问 HDFS
1.前言 hdfs , Hadoop Distributed File System.Hadoop的分布式文件系统,安全行和扩展性没得说. 访问HDFS的方式有以下几种: 命令行方式:FS Shell ...
- Bootstrap历练实例:输入框组的大小
<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content=&q ...