HDOJ 5605-geometry【数学】

客官°小女子只卖身不卖艺 2022-08-19 15:14 239阅读 0赞

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. 1
  2. 2 1

Sample Output

  1. 4
  2. 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的表达式。只要利用数学中的均值不等式。

Center

  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<algorithm>
  4. using namespace std;
  5. int main()
  6. {
  7. int t;
  8. scanf("%d",&t);
  9. while(t--)
  10. {
  11. int x,y;
  12. scanf("%d%d",&x,&y);
  13. printf("%d\n",2*x*y);
  14. }
  15. return 0;
  16. }

[Image 1]:

发表评论

表情:
评论列表 (有 0 条评论,239人围观)

还没有评论,来说两句吧...

相关阅读