ZOJ 3203 Light Bulb (三分+计算几何)
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu
Description
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
给你H,h,D三个数字
问你影子的长度
可以预想一下
跟h有关的影子的长度的函数是一个由峰值的函数
所以三分解决
#include<cstdio>
#include<string>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<cstring>
#include<set>
#include<queue>
#include<algorithm>
#include<vector>
#include<map>
#include<cctype>
#include<stack>
#include<sstream>
#include<list>
#include<assert.h>
#include<bitset>
#include<numeric>
#define max_v 35
#define eps 10e-6
using namespace std;
double H,h,D;
double f(double l)
{
return D*(h-l)/(H-l)+l;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%lf %lf %lf",&H,&h,&D);
double l=,r=h;
double mid,mmid;
while(fabs(l-r)>eps)
{
mid=(l+r)/;
mmid=(mid+r)/;
if(f(mid)<=f(mmid))
{
l=mid;
}
else
{
r=mmid;
}
}
printf("%0.3lf\n",f(l));
}
return ;
}
/*
题目意思:
给你H,h,D三个数字
问你影子的长度 随着h的变化,影子的长度也会变化(影子的长度包括在地上和墙上的)
可以预想一下
跟h有关的影子的长度的函数是一个由峰值的函数
所以三分解决 */
ZOJ 3203 Light Bulb (三分+计算几何)的更多相关文章
- ZOJ - 3203 Light Bulb(三分)
题意:灯离地面的高度为$H$,人的身高为$h$,灯离墙的距离为$D$,人站在不同位置,影子的长度不一样,求出影子的最长长度. 思路:设人离灯的距离为$x$,当人走到距离灯长度为$L$时,人在墙上的影子 ...
- 三分 --- ZOJ 3203 Light Bulb
Light Bulb Problem's Link: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3203 Mean: ...
- ZOJ 3203 Light Bulb (三分查找)
Light Bulb Time Limit: 1 Second Memory Limit: 32768 KB Compared to wildleopard's wealthiness, h ...
- 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
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 ...
- [清华集训2015]灯泡(浙江大学ZOJ 3203 Light Bulb)
Time Limit: 1 Second Memory Limit: 32768 KB Compared to wildleopard's wealthiness, his brother ...
- ZOJ 3203 Light Bulb( 三分求极值 )
链接:传送门 题意: 求影子长度 L 的最大值 思路:如果 x = 0 ,即影子到达右下角时,如果人继续向后走,那么影子一定是缩短的,所以不考虑这种情况.根据图中的辅助线外加相似三角形定理可以得到 L ...
随机推荐
- PHP ServerPush (推送) 技术的探讨[整理]
需求: 我想做个会员站内通知的功能.不想用以前的ajax查询,听说有个推技术.以下文章介绍的不错,来自转载, ============================================= ...
- cmake 基本命令
1 # CMake 最低版本号要求cmake_minimum_required (VERSION 2.8) 2 项目信息project (Demo2) 3 aux_source_directory 查 ...
- Week3——书上的分析
1.long before=System.currentTimeMills(); long after=System.currentTimeMills(); 该l两句是分别记录了开始过滤和结 ...
- JQuery this和$(this)的区别
this其实是一个Html 元素. $this 只是个变量名,加$是为说明其是个jquery对象. 而$(this)是个转换,将this表示的dom对象转为jquery对象,这样就可以使用jquery ...
- 创建完美SDK的10个技巧
[编者按]本文作者为 Gal Lavinsky,文中将列出10个零基础小技巧,帮你创建完美的Java SDK.文章系国内 ITOM 管理平台 OneAPM 编译呈现.以下为正文. 本文起源于笔者朋友的 ...
- Sun Solairs系统添加裸设备
Sun Solaris系统添加裸设备对表空间进行扩容的大体操作步骤. 1.查看当前卷组信息 --查看当前卷组信息#vxdg list --查看当前卷组中物理磁盘的使用情况#vxdg free |gre ...
- SQL Server配置数据库邮件
需求描述 在生产环境中,大部分情况下需要有自己的运维体制,包括自己健康状态的检测等.如果发生异常,需要提前预警的,可以以发邮件告知,邮件作为一种非常便利的预警实现方式,在及时性和易用性方面也有着不可替 ...
- 初始docker
什么是docker? 很多人都是使用docker但是对docker的理解其实并没有这么透彻,只知道怎么用但是不知道为什么用 什么时候去用. 一.环境配置的难题 软件开发最大的麻烦事之一,就是环境配置. ...
- sonar常见
sonar在linux上安装好之后,若之后又更改了sonar的配置,则需要重启服务,重启方法如下: 1.进入到sonar的安装目录下,打开bin目录,会看到所有操作系统的文件夹 2.若操作系统为lin ...
- Nav 切换
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...