标签:1.4 过程 OWIN 中间 角度 ann watch contains tween
描述
Football is one of the most popular words in 2006.
Bob cannot go to Germany for the FIFA world cup 2006 and can only watch the TV instead.
As the following figure, height of the TV is L, and TV is placed at H above Bob‘s eyes, shown in Figure.
Bob want to maximaze the angle α. You need to tell Bob x, the distance between the TV and Bob‘s eyes, when the angle α is maximum.
Attention please, x>=D (or TV will do harm to Bob).
输入
The first line of the input is a positive integer T. T is number of the test cases followed.
Each test case contains three integers L, H, D (-1000<H<1000, 0<L, D< 1000).
There may be one or several spaces before or after the integer.
输出
The output of the program should consist of one line of output for each test case.
The output of each test case only contains x rounded to two decimal places past the decimal point, and always showing the two decimal places past the decimal point.
No any redundant spaces is needed.
样例输入
3
2 -1 10
1 1 1
1 -2 1
样例输出
10.00
1.41
1.41
题目来源
题目链接:http://tzcoder.cn/acmhome/problemdetail.do?&method=showdetail&id=3939
题目大意:Bob想要最大的角度观看世界杯,求出这时候的x值。
题目已经画好了两种情况的图片,根据这两种情况分类讨论。
第二种情况,若H小于L时,那么X越大角度就会越小,所以这时候的X就是题目要求的最小值D
若H大于L是就和第一种情况一样。
第一种情况,x=sqrt(h*H+H*L)是取最小值,证明过程如下:
至于为什么是这个点是极小值,其实感觉一下点越远角度越小,越近角度也越小,所以是一个中间值是角度的最大值,f(x)的极小值,这个不做证明了,下图给出f(x)的大致图像
emmm,我几何全忘了,有简单方法证明可以联系我,告诉我一下,本人不擅长向量法。
#include<stdio.h> #include<math.h> int main() { double l,h,d,p; int n; scanf("%d",&n); while(n--) { scanf("%lf %lf %lf",&l,&h,&d); if(-h<=l&&h<0)p=d; else p=sqrt(l*h+h*h); if(p<d)p=d; printf("%.2lf\n",p); } return 0; }
TZOJ--3939: FIFA World Cup 2006(几何公式)
标签:1.4 过程 OWIN 中间 角度 ann watch contains tween
原文地址:https://www.cnblogs.com/Anidlebrain/p/10055997.html