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 ...
随机推荐
- vmware下载存储vmdk文件后缀变-flat处理方式
将vmware存储中的虚拟机vmdk文件下载到本地,下载完成后,下载了2个vmdk文件 一份为:xx.vmdk (通常1KB左右) 一份为:xx-flat.vmdk (此为源文件正常大小) ...
- Javaweb查询客户&分页部分代码
pageBean工具类代码(分页工具) package com.home.domain; import java.util.List; /** * 分页的JavaBean * @author Admi ...
- org.springframework.data.redis.cache.RedisCacheManager
org.springframework.data.redis.cache.RedisCacheManager
- 用JS实现的常见几种排序算法
1.快速排序法 function quickSort(a) { if (a.length <= 1) { return a; } var midLength = Math.floor(a.len ...
- CSS 小结笔记之背景
背景相关属性主要有: background-color 背景颜色 background-image 背景图片 background-repeat 是否平铺 repeat (默认平铺) | repea ...
- [翻译] 扩张卷积 (Dilated Convolution)
英文原文: Dilated Convolution 简单来说,扩张卷积只是运用卷积到一个指定间隔的输入.按照这个定义,给定我们的输入是一个2维图片,扩张率 k=1 是通常的卷积,k=2 的意思是每个输 ...
- leetCode题解之寻找插入位置
1.问题描述 Search Insert Position Given a sorted array and a target value, return the index if the targe ...
- Replace-iOS
Replace-iOS https://github.com/MartinRGB/Replace-iOS 看了下demo,运行起来超卡...... Simply Implement Zee Young ...
- Custom Settings.in 配置信息收集
[Settings] Priority=Default Properties=MyCustomProperty [Default] ;是否允许部署操作系统到目标计算机 OSInstall=YES ;是 ...
- Python学习---IO的异步[自定义异步IO]
自定义IO异步基础知识: --所有的请求都基于socket实现,一个请求就是一个socket socket.setblocking(False) 不需要阻塞,一个请求完了发送另外一个,会报错,需解决 ...