zoukankan      html  css  js  c++  java
  • [poj][3301][Texas Trip]

    题目:http://poj.org/problem?id=3301

    View Code
    #include <cstdio>
    #include <cmath>
    #include <cstring>
    #include <algorithm>
    
    using namespace std;
    
    const double M = 1e99;
    const double pi = acos(-1.0);
    const double eps = 1e-8;
    
    struct node
    {
        double x, y;
        void get(){ scanf("%lf%lf", &x, &y); }
    }p[40];
    
    int T, n;
    
    double len(double f){
        double l=M, r=-M, d=M, u=-M, x, y;
        for (int i=0; i<n; i++){
            x = cos(f)*p[i].x - sin(f)*p[i].y;
            y = sin(f)*p[i].x + cos(f)*p[i].y;
            l = min(l, x); r = max(r, x);
            d = min(d, y); u = max(u, y);
        }
        return max(r-l, u-d);
    }
    
    void solve(){
        double mid, midmid, lef, rig;
        for (lef=0, rig=pi/2; lef+eps<=rig;){
            mid = (lef + rig) / 2;
            midmid = (mid + rig) / 2;
            if (len(mid)>=len(midmid))lef=mid;
            else rig=midmid;
        }
        printf("%.2f\n", len(lef)*len(lef));
    }
    
    int main()
    {
        //freopen("D:/10101441/a.txt", "r", stdin);
        scanf("%d", &T);
        while (T--){
            scanf("%d", &n);
            for (int i=0; i<n; i++)p[i].get();
            solve();
        }
        return 0;
    }
  • 相关阅读:
    ctrl+shift+k取消
    ERROR 1872
    swap
    mysql主从跳过错误
    undo
    gtid
    falcon监控指标
    连接数
    datetime与timestamp相互转换
    截取文件内容
  • 原文地址:https://www.cnblogs.com/nigel0913/p/2587986.html
Copyright © 2011-2022 走看看