HDOJ 5605-geometry【数学】
geometry
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 262 Accepted Submission(s): 195
Problem Description
There is a point P![Image 1][] at coordinate (x,y)![Image 1][].
A line goes through the point, and intersects with the postive part of X,Y![Image 1][] axes at point A,B![Image 1][].
Please calculate the minimum possible value of |PA|∗|PB|![Image 1][].
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![Image 1][], 0<X,Y≤10000![Image 1][].
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.
Source
BestCoder Round #68 (div.2)
解题思路:
题目大意就是 在平面直角坐标系上有一个点 PP , 他的坐标是 (x, y)(x,y) . 有一条直线 y = kx + by=kx+b 经过了 PP , 且分别交 x, yx,y 正半轴于 A, BA,B . 求 |PA| * |PB|∣PA∣∗∣PB∣ 的最小值.
利用数学化简将∣PA∣∗∣PB∣化简成只含x和y的表达式。只要利用数学中的均值不等式。
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int x,y;
scanf("%d%d",&x,&y);
printf("%d\n",2*x*y);
}
return 0;
}
[Image 1]:
还没有评论,来说两句吧...