• poj 3301 Texas Trip 夜


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

    都说这个题是三分题目 但它不是单峰吧 好怀疑 

    我根据网上的代码写的  连第二组数据都过不了 但交上去 0ms 过啦

    建议不要做这道题 如果有高手指点 那就跟好了

    #include<iostream>
    #include<cstdio>
    #include<queue>
    #include<cstring>
    #include<set>
    #include<cmath>
    #include<algorithm>
    
    using namespace std;
    
    const int N=1005;
    const double M=1000000.0;
    const double PI=acos(-1.0);
    const double eps=1e-10;
    int x[N];
    int y[N];
    double sidemax(double k,int n)
    {
        double x1,x2,y1,y2;
        x1=y1=M;
        x2=y2=-M;
        double xtemp,ytemp;
        for(int i=0;i<n;++i)
        {
            xtemp=x[i]*cos(k)-y[i]*sin(k);
            ytemp=y[i]*cos(k)+x[i]*sin(k);
            //cout<<xtemp<<" "<<ytemp<<endl;
            x1=min(x1,xtemp);
            x2=max(x2,xtemp);
            y1=min(y1,ytemp);
            y2=max(y2,ytemp);
        }
        //cout<<x1<<" "<<x2<<endl;
        return max(y2-y1,x2-x1);
    }
    int main()
    {
        //freopen("data.txt","r",stdin);
        int T;
        scanf("%d",&T);
        while(T--)
        {
            int n;
            scanf("%d",&n);
            for(int i=0;i<n;++i)
            scanf("%d %d",&x[i],&y[i]);
            double l=0.0;
            double r=PI/2.0;
            //int I=0;
            while((r-l)>eps)
            {
                //cout<<++I<<endl;
                //cout<<l<<" TTTT "<<r<<endl;
                double mid=(r+l)/2.0;
                double midr=(mid+r)/2.0;
                if(sidemax(mid,n)<sidemax(midr,n))
                {
                    r=midr;
                }else
                {
                    l=mid;
                }
            }
            printf("%.2f\n",sidemax(l,n)*sidemax(l,n));
    
        }
        return 0;
    }
    
  • 相关阅读:
    bzoj 1406 数论
    bzoj 1927 网络流
    【HNOI】 攻城略池 tree-dp
    【HNOI】五彩斑斓 模拟
    linux下nano命令大全
    CentOS7.6下安装MySQL
    CentOS7.6下安装Oracle JDK
    Vue报错type check failed for prop
    图像分割
    提升方法(boosting)详解
  • 原文地址:https://www.cnblogs.com/liulangye/p/2614842.html
Copyright © 2020-2023  润新知