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,Y≤10000.

 
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)的更多相关文章

  1. BestCoder Round #68 (div.2) tree(hdu 5606)

    tree Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submis ...

  2. Codeforces Round #249 (Div. 2)B(贪心法)

    B. Pasha Maximizes time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  3. BestCoder Round 69 Div 2 1001&& 1002 || HDU 5610 && 5611

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=5610 如果杠铃总质量是奇数直接impossible 接着就考验耐心和仔细周全的考虑了.在WA了三次后终于发 ...

  4. BestCoder Round #50 (div.1) 1002 Run (HDU OJ 5365) 暴力枚举+正多边形判定

    题目:Click here 题意:给你n个点,有多少个正多边形(3,4,5,6). 分析:整点是不能构成正五边形和正三边形和正六边形的,所以只需暴力枚举四个点判断是否是正四边形即可. #include ...

  5. BestCoder Round #68 (div.2)

    并查集 1002 tree 题意:中文题面 分析:(官方题解)把每条边权是1的边断开,发现每个点离他最近的点个数就是他所在的连通块大小. 开一个并查集,每次读到边权是0的边就合并.最后Ansi=siz ...

  6. BestCoder Round #68 (div.2) 1002 tree

    题意:给你一个图,每条边权值0或1,问每个点周围最近的点有多少个? 思路:并查集找权值为0的点构成的连通块. #include<stdio.h> #include<string.h& ...

  7. Codeforces Round #272 (Div. 1)D(字符串DP)

    D. Dreamoon and Binary time limit per test 2 seconds memory limit per test 512 megabytes input stand ...

  8. Codeforces Round #532 (Div. 2)- C(公式计算)

    NN is an experienced internet user and that means he spends a lot of time on the social media. Once ...

  9. Codeforces Round #527 (Div. 3)F(DFS,DP)

    #include<bits/stdc++.h>using namespace std;const int N=200005;int n,A[N];long long Mx,tot,S[N] ...

随机推荐

  1. LA 3516 (计数 DP) Exploring Pyramids

    设d(i, j)为连续子序列[i, j]构成数的个数,因为遍历从根节点出发最终要回溯到根节点,所以边界情况是:d(i, i) = 1; 如果s[i] != s[j], d(i, j) = 0 假设第一 ...

  2. CodeForces Round #290 Fox And Dinner

    而是Div2的最后一题,当时打比赛的时候还不会最大流.自己能够把它写出来然后1A还是很开心的. 题意: 有n个不小于2的整数,现在要把他们分成若干个圈.在每个圈中,数字的个数不少于3个,而且相邻的两个 ...

  3. Lambda表达式【转】

    lambda表达式是对匿名方法的一种改进,具有更加简洁的语法和更易理解的形式,lambda表达式可以包括表达式和语句,并且可以用与创建委托或表达式目录树类型. lambda表达式都使用Lambda运算 ...

  4. tomcat 默认项目设置

    正常情况下,我们启动tomcat后,直接输入“http://localhost:端口/“ 后,默认访问道是webapp目录下的ROOT应用. 我们要通过上述方式访问自己的应用,有俩种方式. 第一:把自 ...

  5. windows安装TortoiseGit详细使用教程【基础篇】

    标签:tortoisegit 环境:win8.1 64bit 安装准备: 首先你得安装windows下的git msysgit1.9.5 安装版本控制器客户端tortoisegit  tortoise ...

  6. 浏览器检测是否安装flash插件,若没有安装,则弹出安装提示

    说白了其实就是在html中前途flash的使用代码 <!--    html嵌入flash,检测浏览器是否安装flash插件,并提示安装.-->    <object type=&q ...

  7. I.MX6 Power off register hacking

    /*********************************************************************** * I.MX6 Power off register ...

  8. Android精美的日历控件

    网上看到的精美日历控件,谨以此文记录一下,用到的时候再来翻翻 源码地址 : http://download.csdn.net/detail/abc13939746593/7265459

  9. js把div固定在页面的右下角

    在公司做材料系统中,需要做一个总是居于右下角的div,但是因为右边这部分本就是用iframe做的,所以是不好弄的. 一开始,以为用position:fixed,一句css就可以完成,结果在iframe ...

  10. 在PC上收发短信--Pidgin短信(Linux Pidgin插件)

    Pidgin短信是Pidgin/empathy的一个插件.当手机收到短信进,电脑上面有提示:可以在电脑上发手机短信.让你时刻保持在电脑屏幕上,也不会错过短信.目前只支持安卓,wifi连接方式. 功能 ...