您的位置:首页 > 其它

hdoj geometry 5605 (简单数学规律)

2016-01-02 22:04 337 查看

geometry

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

Total Submission(s): 59    Accepted Submission(s): 45


[align=left]Problem Description[/align]
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|.

[align=left]Input[/align]
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.

[align=left]Output[/align]
T lines,each line contains a number,means the answer to each test case.

[align=left]Sample Input[/align]

1
2 1

[align=left]Sample Output[/align]

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.

[align=left]Source[/align]
BestCoder Round #68 (div.2)

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
int t,x,y,b;
double s,xx,yy;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&x,&y);
b=x+y;
xx=sqrt((x*x)+(b-y)*(b-y));
yy=sqrt((y*y)+(b-x)*(b-x));
s=xx*yy;
printf("%.0lf\n",s);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: