码迷,mamicode.com
首页 > 其他好文 > 详细

geometry(简单数学题)

时间:2016-01-02 22:18:48      阅读:206      评论:0      收藏:0      [点我收藏+]

标签:

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=2?2???,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;
}

  

geometry(简单数学题)

标签:

原文地址:http://www.cnblogs.com/handsomecui/p/5095269.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!