hdu 3532 Max Angle(atan2的使用)

Max Angle

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 678    Accepted Submission(s): 238

Problem Description
Given many points in a plane, two players are playing an interesting game.

Player1 selects one point A as the vertex of an angle. Then player2 selects other two points B and C. A, B and C are different with each other. Now they get an angle B-A-C.

Player1 wants to make the angle as large as possible, while player2 wants to make the angle as small as possible.

Now you are supposed to find the max angle player1 can get, assuming play2 is c lever enough.

 

 

Input
There are many test cases. In each test case, the first line is an integer n (3 <= n <= 1001), which is the number of points on the plane. Then there are n lines. Each contains two floating number x, y, witch is the coordinate of one point. n <= 0 denotes the end of input.
 

 

Output
For each test case, output just one line, containing the max angle player1 can get in degree format. The result should be accurated up to 4 demicals.
 

 

Sample Input
3
0 0
2 0
0 5
-1
 

 

Sample Output
90.0000
 

 

Source
 

 

题意是说。先选一个点A,然后选两个点B,C。 使得每个A对应的最小角B-A-C最大。
 
我们可以枚举每个点,然后求得这个点和其他所有点所成的角度,排序后找到一组相邻的差值最小的,记录为mn
然后对于每个点得到的mn,记录最大的一个,就是答案。
 
角度怎么搞呢…
atan2(y,x)是个好东西。
atan2(y,x)表示点(0,0)到(x,y)的射线与x轴正向所成的角度,取值范围介于 -pi 到 pi 之间(不包括 -pi),
 
我们可以处理下把角度变成0到2*pi之间。
 

还要注意直线的角度不可能是钝角。所以如果答案为钝角记得取补。
 
1A,开心。
 

View Code

 

 
Posted in ACM

说点什么

您将是第一位评论人!

提醒
wpDiscuz