zoj 3023 Light Bulb
题目大意:

求L的最大值
思路:
可以想象出是一个关于人到灯泡距离x的单峰上凸函数
当光线在墙角左边的时候影子在不断增长
然后通过相似可以推出人在墙上影子的长度为:H+D*(h-H)/x
再加上地上的D-x就可以计算出每个x的函数值了
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#define inf 2139062143
#define ll long long
#define MAXN 1001000
#define eps 1e-4
using namespace std;
inline int read()
{
int x=,f=;char ch=getchar();
while(!isdigit(ch)) {if(ch=='-') f=-;ch=getchar();}
while(isdigit(ch)) {x=x*+ch-'';ch=getchar();}
return x*f;
}
double H,h,d;
double calc(double x){return H+(h*d-H*d)/x+d-x;}
int main()
{
int T=read();
while(T--)
{
scanf("%lf%lf%lf",&H,&h,&d);
double r=d,l=d-h*d/H,ml,mr;
while(r-l>eps)
{
ml=(r-l)/3.0+l,mr=*(r-l)/3.0+l;
if(calc(ml)>calc(mr)) r=mr;
else l=ml;
}
printf("%.3lf\n",calc(r));
}
}
zoj 3023 Light Bulb的更多相关文章
- 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 Problem's Link: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3203 Mean: ...
- 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 (三分查找)
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 ...
随机推荐
- sysbench--mysql测试
1.下载sysbench-0.4.12.14.tar.gz 2.解压.tar -zxf sysbench-0.4.12.14.tar.gz 3.编译: 填写mysql路劲. ./configure - ...
- 又是latch: cache buffers chains惹得祸
前言 一大早,客户给我打电话说: xx,应用很慢,查询数据总是超时,让我看看... 根据多年DBA经验,首当其冲的肯定是去查询数据库在这段时间都在干嘛. 分析 导出awr报告分析 1). 数据库在此时 ...
- Html、Css、JavaScript 遇到的问题总结
$('body').scrollTop()无效得解决方案 鼠标滑轮获取到得值为0:var scrollTop = $('body').scrollTop(); 在页面中加一个随着页面滚动条滚动的小图片 ...
- Python 中的变量还能这样理解(白话)
一.案例分析 1.思考 计算软件测试大佬柠檬小姐姐,每月能存多少钱 # 计算软件测试大佬柠檬小姐姐,每月能存多少钱 # 坐标:深圳 # 2018年1月份 # 房租水电 4000元 # 伙食费 1000 ...
- 配置Django+mysql+pydev(x64)
mysqldb需要安装64位的(http://ishare.iask.sina.com.cn/f/21839771.html),否则出现 import _mysql ImportError: DLL ...
- 集训第四周(高效算法设计)O题 (构造题)
A permutation on the integers from 1 to n is, simply put, a particular rearrangement of these intege ...
- BNUOJ 5629 胜利大逃亡(续)
胜利大逃亡(续) Time Limit: 2000ms Memory Limit: 32768KB This problem will be judged on HDU. Original ID: 1 ...
- Django:(4)Django和Ajax
向服务器发送请求的途径: 1. 浏览器地址栏,默认get请求 2. form表单: get请求: post请求 3. a标签,默认get请求 4. Ajax:get请求:post请求 Ajax的特点( ...
- Ubuntu 16.04安装录屏软件SimpleScreenRecorder
安装: sudo add-apt-repository ppa:maarten-baert/simplescreenrecorder sudo apt-get update sudo apt-get ...
- ubuntu Install Firefox
Firefox 下载文件以.tar和.bz2格式保存,必须从这些压缩包中提取文件.不想删除当前安装的 Firefox,给每个版本的 Firefox 创建一个单独的文件夹. 例如:1.Firefox 版 ...