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| .
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,Y≤10000 .
the next T lines there are two positive integers X,Y,means the coordinates of P.
T=500 , 0<X,Y≤10000 .
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;
}