ZOJ 3203 Light Bulb【可求出极值的单峰函数】
来源:互联网 发布:淘宝客和返利网是什么 编辑:程序博客网 时间:2024/04/28 00:36
链接:
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
32 1 0.52 0.5 34 3 4
Sample Output
1.0000.7504.000
Author: GUAN, Yao
Source: The 6th Zhejiang Provincial Collegiate Programming Contest
算法:利用函数的凸性
思路一:
学妹的思路:三分 L
code:
#include<stdio.h>#include<string.h>#include<math.h>int main(){ int T; double H,h,D; scanf("%d", &T); while(T--) { scanf("%lf%lf%lf", &H,&h,&D); double x1 = (H-h)*D/H; double x2 = D; double x0 = sqrt(D*(H-h)); double x; if(x1 <= x0 && x0 <= x2) x = x0; else if(x0 <= x1) x = x1; else if(x0 >= x2) x = x2; double ans = D+H- (x + (H-h)*D/x); printf("%.3lf\n", ans); } return 0;}
- ZOJ 3203 Light Bulb【可求出极值的单峰函数】
- ZOJ 3203 Light Bulb——(三分求极值)
- zoj 3203 Light Bulb 三分,求凸函数的最大值
- ZOJ 3203 Light Bulb
- ZOJ - 3203 Light Bulb
- ZOJ 3203 Light Bulb
- Zoj 3203 Light Bulb
- zoj 3203 Light Bulb
- ZOJ 3203 Light Bulb
- zoj 3203(Light Bulb)
- ZOJ 3203 Light Bulb
- ZOJ 3203 Light Bulb
- zoj 3203 Light Bulb
- ZOJ 3203 Light Bulb
- zoj 3203 Light Bulb
- zoj 3203 Light Bulb
- ZOJ 3203 Light Bulb
- ZOJ 3203 Light Bulb
- hdu 2473 Junk-Mail Filter
- 简单多线程
- 字符编码介绍
- Organizing Your Speech
- [leetcode刷题系列]Binary Tree Level Order Traversal II
- ZOJ 3203 Light Bulb【可求出极值的单峰函数】
- Java中堆内存与栈内存分配浅析(重点已做记号)
- Stage Performance
- C#试题
- Java多线程——3 任务的提交者和执行者Executor
- 设计模式之路--综述
- 基于MFC的ActiveX控件开发
- jxl的api--java解析Excel
- 苍白和无赖的android应用