zoukankan      html  css  js  c++  java
  • 厦门大学 ACM 1437 三分

    链接http://acm.xmu.edu.cn/JudgeOnline/problem.php?id=1437

    #include<iostream>
    #include<algorithm>
    #include<stdio.h>
    #include<cstring>
    #include<cmath>
    using namespace std;
    const double PI  = acos(-1.0);
    const double EPS = 1e-10;
    struct date
    {
        double x,y;
    }lt,rt,ml,mr;
    inline double max( double a,double b ){return a>b?a:b;}
    double work( date temp )
    {
        double a = mr.x - ml.x;
        double b =  pow(temp.x - ml.x,2) + pow(temp.y - ml.y,2);
        double c =  pow(temp.x - mr.x,2) + pow(temp.y - mr.y,2);
        double res = (b+c-a*a)/(2.*sqrt(b)*sqrt(c));
        return acos(res)*180/PI;
    }
    int main( )
    {
        date ans1,ans2; double res1,res2;
        while( scanf("%lf%lf%lf",&ml.x,&mr.x,&mr.y) != EOF )
        {
            ml.y = mr.y;
            scanf("%lf%lf%lf%lf",&lt.x,&lt.y,&rt.x,&rt.y);
            double ang = 0;
            if( lt.y == mr.y && lt.x >= ml.x && lt.x <= mr.x )
            {
                printf("180.00000000\n");
                continue;
            }
            if( rt.y == mr.y && rt.x >= ml.x && rt.x <= mr.x )
            {
                printf("180.00000000\n");
                continue;
            }
            if( lt.y == rt.y && lt.y == mr.y )
            if( lt.x <= ml.x && rt.x >= mr.x )
            {
                printf("180.00000000\n");
                continue;
            }
            while( abs(rt.x - lt.x) > 0.00000000001 || abs(rt.y - lt.y) > 0.00000000001 )
            {
                ans1.x = ( lt.x+lt.x+rt.x )/3.;
                ans1.y = ( lt.y+lt.y+rt.y )/3;
    
                ans2.x = ( rt.x+rt.x+lt.x )/3.;
                ans2.y = ( rt.y+rt.y+lt.y )/3;
    
                res1 = work(ans1); res2 = work(ans2);
                if( res1 < res2 )
                     lt = ans1;
                else rt = ans2;
                ang = max( res1,res2 );
            }
            printf("%.8lf\n",ang);
        }
        return 0;
    }
    

      

  • 相关阅读:
    超链接与图像
    24
    2018-02-24
    2018-02-23
    2018-02-05(jQuery)
    2018-01-29(jQuery)
    2018-01-29(Bootstrap)
    2018-01-29(HTML+CSS)
    451. 根据字符出现频率排序
    550.键盘行
  • 原文地址:https://www.cnblogs.com/wulangzhou/p/3078032.html
Copyright © 2011-2022 走看看