zoukankan      html  css  js  c++  java
  • 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,Yleq 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|=2sqrt{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
    ",2*x*y);
    	}
    	return 0;
    }
    

      

  • 相关阅读:
    WSP_mainActivity
    使用Xutils(HttpUtils)请求网络数据
    ScrollView横向滑动与fragment的联动
    侧滑菜单
    Pull解析xml文件
    Xlistview的应用1(上拉刷新,下拉加载)fragment
    XlistView4(脚部刷新)
    XlistView3(头部的代码)
    GCD队列组的使用
    GCD栅栏函数dispatch_barrier
  • 原文地址:https://www.cnblogs.com/handsomecui/p/5095269.html
Copyright © 2011-2022 走看看