BestCoder Round #68 (div.2) geometry(hdu 5605)

geometry

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

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,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.
 
题意:给你一点p的坐标(x,y)现在一条直线过p点分别与X,Y正半轴交于点A,B,求PA*PB最小值
题解:
BestCoder Round #68 (div.2) geometry(hdu 5605)
如图:PA=AC/sinθ,  PB=OC/sinθ    所以PA*PB=(AC*OC)/(sinθ*sinθ)  因为AC=PC*tanθ  PC=x,OC=y所以 PA*PB=(x*y)/(sinθ*cosθ)
所以当sinθ*cosθ最大时结果最小,此时θ等于45度所以PA*PB=x*y*2
#include<stdio.h>
#include<string.h>
#include<string>
#include<math.h>
#include<algorithm>
#define LL long long
#define PI atan(1.0)*4
#define DD doublea
#define MAX 1010
#define mod 10007
using namespace std;
int main()
{
int n,m,j,i,s,t;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&m);
printf("%d\n",n*m*2);
}
return 0;
}

  

上一篇:R cannot be resolved to a variable问题


下一篇:Linux 系统中用户切换(su user与 su - user 的区别)