TZOJ--3939: FIFA World Cup 2006(几何公式)

3939: FIFA World Cup 2006

时间限制(普通/Java):1000MS/3000MS     内存限制:65536KByte

描述

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

题目来源

TOJ

题目链接: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;
}

  

原文地址:https://www.cnblogs.com/Anidlebrain/p/10055997.html

时间: 2024-10-12 12:16:47

TZOJ--3939: FIFA World Cup 2006(几何公式)的相关文章

ZOJ 3598 Spherical Triangle球面几何公式应用

#include <map> #include <set> #include <list> #include <cmath> #include <ctime> #include <deque> #include <stack> #include <queue> #include <cctype> #include <cstdio> #include <string> #inc

几何公式

两条直线是否相交 1 //叉积 2 double mult(Point a, Point b, Point c) 3 { 4 return (a.x-c.x)*(b.y-c.y)-(b.x-c.x)*(a.y-c.y); 5 } 6 7 //aa, bb为一条线段两端点 cc, dd为另一条线段的两端点 相交返回true, 不相交返回false 8 bool intersect(Point aa, Point bb, Point cc, Point dd) 9 { 10 if ( max(aa.

PAT (Advanced Level) Practice 1011 World Cup Betting (20 分)

With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battles for the World Cup trophy in South Africa. Similarly, football betting fans were putting their

PAT 1011 World Cup Betting 查找元素

With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battles for the World Cup trophy in South Africa. Similarly, football betting fans were putting their

pat1011. World Cup Betting (20)

1011. World Cup Betting (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battl

POJ1953 World Cup Noise

这题纯暴力会超时,只需简单推一下递推公式即可,其实就是一个斐波拉契数列. World Cup Noise Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 15937   Accepted: 7861 Description Background "KO-RE-A, KO-RE-A" shout 54.000 happy football fans after their team has reached the

1011. World Cup Betting (20)

1011. World Cup Betting (20) With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battles for the World Cup trophy in South Africa. Similarly, football bet

1011. World Cup Betting (20)(最大值)

With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battles for the World Cup trophy in South Africa. Similarly, football betting fans were putting their

PAT1011. World Cup Betting

With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battles for the World Cup trophy in South Africa. Similarly, football betting fans were putting their