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 ...
随机推荐
- 在ASP.NET中,后台代码向页面写HTML代码
Literal lt = new Literal();lt.Text = "<a href=\"http://www.czbin.cn\">czbin的博客& ...
- find搜索文件系统,实时搜索
find搜索文件系统.实时搜索 find[目录][条件][动作] [目录] 不输入目录代表当前目录 find find /etc ----------------------------------- ...
- 制作 Favicon.ico 图标教程
摘要:有一些站长认为 favicon.ico 图标对于一个网站没有什么作用.甚至有一些站长认为,少加载一个图片,页面设计展现的速度更快些.的确,理论上是对的,但乐猪认为这种想法是肤浅的!有这种想法的站 ...
- spring @RequestBody 和 @RequestParams 同时使用
@RequestBody 和 @RequestParams 是可以同时使用的. @RequestBody 接受的数据类型是 content-type:"application/json&qu ...
- 添加 SSH 公钥
生成 SSH 密钥 ssh-keygen -t rsa -C "YOUR_EMAIL@YOUREMAIL.COM" 获取 SSH 公钥信息 cat ~/.ssh/id_rsa.pu ...
- LVM逻辑分区的优缺点与步骤
一.LVM简介 1. 什么是LVM? LVM是 Logical Volume Manager(逻辑卷管理)的简写 2. 为什么使用LVM? LVM通常用于装备大量磁盘的系统,但它同样适于仅有一.两块硬 ...
- Gradle环境下导出Swagger为PDF
更多精彩博文,欢迎访问我的个人博客 说明 我个人是一直使用Swagger作为接口文档的说明的.但是由于在一些情况下,接口文档说明需要以文件的形式交付出去,如果再重新写一份文档难免有些麻烦.于是在网上看 ...
- 浅谈web前端开发
我个人认为前端攻城狮其实就是编程技术人员,用一句话来形容“比UI设计懂技术,比技术人员更懂交互”,当然也有人说前端工程师是工程师中的设计师,是设计师中的工程师. 好了废话不多说了,下面进入正题吧! ...
- 数据库:SQL Server自增长列的编号
SQL Server表中的自动编号ID重新开始排列 说法一: 有两种方法: 方法1: truncate table 你的表名 --这样不但将数据删除,而且可以重新置位identity属性的字段. 方法 ...
- C02 信息存储与运算
目录 计算机内存 常量和变量 数据类型 运算符 计算机内存管理 计算机内存 信息存储概述 使用程序进行开发时,需要存储各种信息,这时候就需要用到变量.由于信息类型不同,变量的类型也因此不尽相同. 同时 ...