Max Angle //2010 ACM-ICPC Multi-University Training Contest(10)——Host by HEU
2010-08-29 19:26
651 查看
Max Angle
Time Limit : 4000/2000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other)Total Submission(s) : 12 Accepted Submission(s) : 5
Font: Times New Roman | Verdana | Georgia
Font Size: ← →
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
2010 ACM-ICPC Multi-University Training Contest(10)——Host by HEU#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const double pi=acos(-1+0.0);
struct node
{
double x,y;
};
double dis(node a, node b)
{
return sqrt((a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y));
}
int main()
{
int n;
node a[1100];
double t[1100];
while(scanf("%d",&n)==1&&n>0)
{
for(int i=0;i<n;i++) scanf("%lf%lf",&a[i].x,&a[i].y);
double cnt=0;
for(int i=0;i<n;i++)
{
int l=0;
for(int j=0;j<n;j++)
{
if(i==j) continue;
t[l++]=acos((a[j].x-a[i].x)/dis(a[i],a[j]));
if(a[j].y<a[i].y) t[l-1]=2*pi-t[l-1];
}
sort(t,t+l);
double _min=2*pi-t[l-1]+t[0];
for(int i=1;i<l;i++) if(t[i]-t[i-1]<_min) _min=t[i]-t[i-1];
if(_min>cnt) cnt=_min;
}
printf("%.4lf/n",cnt*180/pi);
}
return 0;
}
相关文章推荐
- SPY //2010 ACM-ICPC Multi-University Training Contest(10)——Host by HEU
- Tree //2010 ACM-ICPC Multi-University Training Contest(10)——Host by HEU
- Subsequence //2010 ACM-ICPC Multi-University Training Contest(10)——Host by HEU
- Computer Assembling //2010 ACM-ICPC Multi-University Training Contest(10)——Host by HEU
- hdu 2010 ACM-ICPC Multi-University Training Contest(1)——Host by FZU(杯具了)
- 2010 ACM-ICPC Multi-University Training Contest(11)——Host by BUPT
- 2010 ACM-ICPC Multi-University Training Contest(12)——Host by WHU 部分题目解题报告
- hdu 3572 Task Schedule(最大流)2010 ACM-ICPC Multi-University Training Contest(13)——Host by UESTC
- HDU 3605 Escape 最大流or二分图多重匹配 2010 ACM-ICPC Multi-University Training Contest(17)——Host by ZSTU
- 2010 ACM-ICPC Multi-University Training Contest(2)——Host by BUPT
- hdu 3496 Watch The Movie //2010 ACM-ICPC Multi-University Training Contest(6)——Host by BIT
- hdu 3491 Thieves //2010 ACM-ICPC Multi-University Training Contest(6)——Host by BIT
- HDU 3602 2012(2010 ACM-ICPC Multi-University Training Contest(16)——Host by NUDT)
- HDU3523 Image copy detection 最小权匹配KM 2010 ACM-ICPC Multi-University Training Contest(9)——Host by HNU
- HDU 3488 Tour //2010 ACM-ICPC Multi-University Training Contest(6)——Host by BIT
- 2010 ACM-ICPC Multi-University Training Contest(14)——Host by BJTU
- Hdu 3936 FIB Query[矩阵快速幂](2011 Multi-University Training Contest 10 - Host by HRBEU)
- 2009 Multi-University Training Contest 10 - Host by NIT
- HDU 3902 Swordsman 2011 Multi-University Training Contest 7 - Host by ECNU 计算几何
- 2016 Multi-University Training Contest 10 solutions BY BUPT