geometry(简单数学题)

geometry

 
 Accepts: 324
 
 Submissions: 622
 Time Limit: 2000/1000 MS (Java/Others)
 
 Memory Limit: 65536/65536 K (Java/Others)
Problem Description

There is a point PP at coordinate (x,y)(x,y). A line goes through the point, and intersects with the postive part of X,YX,Y axes at point A,BA,B. Please calculate the minimum possible value of |PA|*|PB|PAPB∣.

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=500T=500,0< X,Y\leq 100000<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)P(2,1),we make the line y=-x+3y=x+3,which intersects the
positive axis of X,YX,Y at (3,0),(0,3).|PA|=\sqrt{2},|PB|=2\sqrt{2},
|PA|*|PB|=4PA=2​​,PB=22​​,PAPB=4,the answer is checked to be the best answer.
题解:简单高中数学题,算下就可以得到2xy;
代码:
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
#define mem(x,y) memset(x,y,sizeof(x))
#define SI(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define  PI(x) printf("%d",x)
#define  PL(x) printf("%lld",x)
#define P_ printf(" ")
const int INF=0x3f3f3f3f;
const double PI=acos(-1.0);
int main(){
	int T,x,y;
	SI(T);
	while(T--){
		SI(x);SI(y);
		printf("%d\n",2*x*y);
	}
	return 0;
}

  

posted @ 2016-01-02 21:06  handsomecui  阅读(407)  评论(0编辑  收藏  举报