首页 > 其他 > 详细

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

时间:2016-01-31 02:34:13      阅读:142      评论:0      收藏:0      [点我收藏+]

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,Y10000.
 

 

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最小值
题解:
技术分享
如图: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;
} 

  

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

原文:http://www.cnblogs.com/tonghao/p/5172282.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!