B - 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的变化,影子的长度也会变化(影子的长度包括在地上和墙上的)
可以预想一下
跟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 (三分+计算几何)的更多相关文章

  1. ZOJ - 3203 Light Bulb(三分)

    题意:灯离地面的高度为$H$,人的身高为$h$,灯离墙的距离为$D$,人站在不同位置,影子的长度不一样,求出影子的最长长度. 思路:设人离灯的距离为$x$,当人走到距离灯长度为$L$时,人在墙上的影子 ...

  2. 三分 --- ZOJ 3203 Light Bulb

    Light Bulb Problem's Link:   http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3203 Mean: ...

  3. ZOJ 3203 Light Bulb (三分查找)

    Light Bulb Time Limit: 1 Second      Memory Limit: 32768 KB Compared to wildleopard's wealthiness, h ...

  4. ZOJ 3203 Light Bulb - 求导求最大值

    如果L全在地面上: 输出 h * D / H 如果L全在墙上: 输出 h 否则: (D - X ) / X = Y / (H - h) L = D - X + h - Y 然后对L求导即可 #incl ...

  5. zoj 3203 Light Bulb,三分之二的基本问题

    Light Bulb Time Limit: 1 Second      Memory Limit: 32768 KB Compared to wildleopard's wealthiness, h ...

  6. ZOJ 3203 Light Bulb

    Compared to wildleopard's wealthiness, his brother mildleopard is rather poor. His house is narrow a ...

  7. ZOJ 3203 Light Bulb(数学对勾函数)

    Light Bulb Time Limit: 1 Second      Memory Limit: 32768 KB Compared to wildleopard's wealthiness, h ...

  8. [清华集训2015]灯泡(浙江大学ZOJ 3203 Light Bulb)

    Time Limit: 1 Second      Memory Limit: 32768 KB Compared to wildleopard's wealthiness, his brother ...

  9. ZOJ 3203 Light Bulb( 三分求极值 )

    链接:传送门 题意: 求影子长度 L 的最大值 思路:如果 x = 0 ,即影子到达右下角时,如果人继续向后走,那么影子一定是缩短的,所以不考虑这种情况.根据图中的辅助线外加相似三角形定理可以得到 L ...

随机推荐

  1. CentOS 7 搭建PXC 数据库集群

    CentOS 7 搭建PXC 数据库集群 PXC( Percona XtraDB Cluster ) 特点如下: 1.同步复制,事务要么在所有节点提交或不提交,保证了数据的强一致性. 2.多主复制,可 ...

  2. maven 安装下载与配置 代理设置 《解决下载慢问题》

    maven:下载地址http://mirror.bit.edu.cn/apache/maven/maven-3/ 解压之后配置环境 %maven_home%  d:\*****path 中添加 %ma ...

  3. 10个经典的Android开源应用项目

    Android开发又 将带来新一轮热潮,很多开发者都投入到这个浪潮中去了,创造了许许多多相当优秀的应用.其中也有许许多多的开发者提供了应用开源项目,贡献出他们的智慧和 创造力.学习开源代码是掌握技术的 ...

  4. FastDFS部署安装全过程

    你好!欢迎阅读我的博文,你可以跳转到我的个人博客网站,会有更好的排版效果和功能. 此外,本篇博文为本人Pushy原创,如需转载请注明出处:https://pushy.site/posts/153205 ...

  5. 查看组成一个Index的column有哪些

    下面是创建一个表,并在上面建立一些index的SQL.我们会新建一个用户,然后再那个schema下运行下面的SQL. create table indtest (f1_num number(10)  ...

  6. apache ftp server的简单入门(properties验证)

    Apache FTPServer:(开源) Apache FTPServer是一个100%纯Java的FTP服务器. 它的设计是基于现有的开放式协议的完整和便携式FTP服务器引擎解决方案.FTPSer ...

  7. PyQt4(使用ui)

    1.使用qt designer设计界面,保存为test1.ui: 2.使用pyuic4 test1.ui -o ui.py生成ui代码. 3.程序载入. import sys import ui fr ...

  8. windows下php使用zerophp

    官网地址:http://zeromq.org/ 下载windows版本安装(不过php可以不用安装,直接使用扩展包就可以了) 然后下载php的zmq扩展包:https://pecl.php.net/p ...

  9. 如何利用fiddler篡改发送请求和截取服务器信息

    一.断点的两种方式 1.before response:在request请求未到达服务器之前打断 2.after response:在服务器响应之后打断 二.全局打断 1.全局打断就是中断fiddle ...

  10. 数据库对比:选择MariaDB还是MySQL?

    作者 | EverSQL 译者 | 无明 这篇文章的目的主要是比较 MySQL 和 MariaDB 之间的主要相似点和不同点.我们将从性能.安全性和主要功能方面对这两个数据库展开对比,并列出在选择数据 ...