hdu5605(基本不等式)

43 篇文章 0 订阅

geometry

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 463    Accepted Submission(s): 353


Problem Description
There is a point  P  at coordinate  (x,y) .
A line goes through the point, and intersects with the postive part of  X,Y  axes at point  A,B .
Please calculate the minimum possible value of  |PA||PB| .
 

Input
the first line contains a positive integer T,means the numbers of the test cases.

the next T lines there are two positive integers X,Y,means the coordinates of P.

T=500 , 0<X,Y10000 .
 

Output
T lines,each line contains a number,means the answer to each test case.



 

Sample Input
  
  
1 2 1
 

Sample Output
  
  
4 in the sample $P(2,1)$,we make the line $y=-x+3$,which intersects the positive axis of $X,Y$ at (3,0),(0,3).$|PA|=\sqrt{2},|PB|=2\sqrt{2},|PA|*|PB|=4$,the answer is checked to be the best answer.
 

//hdu5605(基本不等式推导)
//题目大意:有一个点p(x1,y1);若一直线经过p且与x、y轴的交点分别为A(a,0)、B(0,b);
//问|pA|*|pB|的最小值是多少?
//解题思路就是求p与A、B两点的距离乘积的最小值.就是利用基本不等式a+b>=2*sqrt(a*b);
//最终可得最小值min=2*x1*y1(即p的坐标乘积的2倍)推导如下:
//设直线为:(y-y1)=k(x-x1);则令y=0,可得A点坐标为(-y1/k+x1,0),x=0的B点坐标为(0,-k*x1+y1)
//所以|PA|=sqrt((1 + 1/k^2)*y1^2),|PB|=sqrt(x1^2 + (k*x1)^2);
//|PA|*|PB|=x1*y1*sqrt(k^2 + 1/k^2 + 2)=x1*y1*sqrt((k + 1/k)^2)=x1*y1*(k + 1/k);
//又有k+1/k>=2*sqrt(k*(1/k))=2;即|pA|*|PB|>=2*x1*y1. 
#include<stdio.h>
#include<string.h>
int main()
{
    int t,x,y;
	scanf("%d",&t);
	while(t--)
	{
	   scanf("%d%d",&x,&y);
	   printf("%d\n",2*x*y);	
	}	
	return 0;
} 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

bokzmm

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值