标签:
3
0 0
2 0
0 5
-1
90.0000
/**
2016 - 08 - 04 上午
Author: ITAK
Motto:
今日的我要超越昨日的我,明日的我要胜过今日的我,
以创作出更好的代码为目标,不断地超越自己。
**/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int INF = 1e9+5;
const int MAXN = 1e6+5;
const int MOD = 1e9+7;
const double eps = 1e-7;
const double PI = acos(-1);
struct Point
{
    double x, y;
}p[MAXN];
double Cross(Point a, Point b, Point c)
{
    return (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);
}
double dis(Point a, Point b)
{
    return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}
double num[MAXN];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        if(n <= 0)
            break;
        for(int i=0; i<n; i++)
            scanf("%lf%lf",&p[i].x,&p[i].y);
        double ans = 0;
        for(int i=0; i<n; i++)
        {
            int sum = 0;
            double Min = 5211314;
            for(int j=0; j<n; j++)
            {
                if(i == j)
                    continue;
                double xx = p[j].x - p[i].x;
                double yy = p[j].y - p[i].y;
                num[sum] = atan2(yy,xx)/PI*180;///点(yy,xx) 与 X 轴的夹角
                if(num[sum] < 0)
                    num[sum] += 360;///保证是正数
                sum++;
            }
            sort(num, num+sum);
            double tmp = 0;
            for(int j=1; j<sum; j++)
            {
                tmp = num[j]-num[j-1];///相邻角
                Min = min(tmp, Min);///最小值
            }
            tmp = 360 - num[sum-1] + num[0];
            Min = min(tmp, Min);
            ans = max(ans, Min);
        }
        printf("%.4lf\n",ans);
    }
    return 0;
}
HDU 3532 Max Angle(计算几何——极角排序)
标签:
原文地址:http://blog.csdn.net/qingshui23/article/details/52117009