ZOJ 3203 Light Bulb - 求导求最大值

如果L全在地面上:
输出 h * D / H
如果L全在墙上:
输出 h
否则:
(D - X ) / X = Y / (H - h)
L = D - X + h - Y
然后对L求导即可
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std; int main(){
double H,h,D,x,y,x0;
int t;
scanf("%d",&t);
while(t--){
scanf("%lf%lf%lf",&H,&h,&D);
x0 = D - h * D / H;
x = sqrt( D * (H - h) );
y = (D - x) * (H - h) / x;
if(x >= D) printf("%.3lf\n",h);
else if(x < x0) printf("%.3lf\n",h * D / H);
else printf("%.3lf\n",h - y + D - x);
}
return ;
}
Light Bulb
Time Limit: 1 Second Memory Limit: 32768 KB
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
ZOJ 3203 Light Bulb - 求导求最大值的更多相关文章
- ZOJ 3203 Light Bulb( 三分求极值 )
链接:传送门 题意: 求影子长度 L 的最大值 思路:如果 x = 0 ,即影子到达右下角时,如果人继续向后走,那么影子一定是缩短的,所以不考虑这种情况.根据图中的辅助线外加相似三角形定理可以得到 L ...
- ZOJ 3203 Light Bulb (三分查找)
Light Bulb Time Limit: 1 Second Memory Limit: 32768 KB Compared to wildleopard's wealthiness, h ...
- 三分 --- ZOJ 3203 Light Bulb
Light Bulb Problem's Link: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3203 Mean: ...
- 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,三分之二的基本问题
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 ...
- [清华集训2015]灯泡(浙江大学ZOJ 3203 Light Bulb)
Time Limit: 1 Second Memory Limit: 32768 KB Compared to wildleopard's wealthiness, his brother ...
- ZOJ - 3203 Light Bulb(三分)
题意:灯离地面的高度为$H$,人的身高为$h$,灯离墙的距离为$D$,人站在不同位置,影子的长度不一样,求出影子的最长长度. 思路:设人离灯的距离为$x$,当人走到距离灯长度为$L$时,人在墙上的影子 ...
随机推荐
- 如何修改Protel99SE原理图的标题栏
本文主要讲述了如何修改Protel99SE原理图中的标题栏内容,使用者可以根据需要修改. 标题栏的格式: 1.添加模板:(1)菜单栏Design\Template\Set Template File ...
- BZOJ 1005 明明的烦恼 (组合数学)
题解:n为树的节点数,d[ ]为各节点的度数,m为无限制度数的节点数. 则 所以要求在n-2大小的数组中插入tot各序号,共有种插法: 在tot各序号排列中,插第一个节点的 ...
- JavaBean讲解 规范
一:JavaBean定义 JavaBean是一种可重复使用.跨平台的软件组件.JavaBean可分为两种:一种是有用户界面(UI,User Interface)的JavaBean,例如NetBean中 ...
- Nlog的简单使用
Nlog是.net平台下的开源日志组件,相当于log4net用法配置更简单.用途可以将日志输出到数据库,文本文件,控制台等.首先引用NLog.dll,顺便也将NLog.xml丢到运行目录准备工作完后, ...
- 重启IIS报错:IIS 服务或万维网发布服务,或者依赖这 服务可能在启动期间发生错误或者已禁用
参考文章: http://www.cnblogs.com/zengen/archive/2010/10/29/1864569.html 开启如下服务: Net.Msmq Listener Adapte ...
- C#语言基础之数据类型
数据类型 1.值类型(1)整型:有符号整型和无符号整型. 区别是无符号整型要比有符号整型的正数范围大.2X+1 有符号整型:sbyte,short,int,long 带有正负数,范围按所写依次增大 ...
- centos7/redhat7 将网卡名字改成eth样式的方法
方法/步骤 1. 编辑 /etc/sysconfig/grub 找到“GRUB_CMDLINE_LINUX”这一行
- webviewactivity
WebView注意点,注释里有说明 package com.example.suneyaenews; import com.example.http.HttpThread; import androi ...
- GIT简易使用流程
git是目前世界上最先进的分布式版本控制系统(摘自廖雪峰官网) 首先需要在系统上安装git: Windows系统在这下载: RHEL/Centos/Fedora用户可以用以下命令安装:yum -y i ...
- 教你怎么用Mono Cecil - 动态注入 (注意代码的注释)
原文 教你怎么用Mono Cecil - 动态注入 (注意代码的注释) 使用 Mono Cecil 进行反编译:using Mono.Cecil; using Mono.Cecil.Cil; //.. ...