zoukankan      html  css  js  c++  java
  • 今天HNU的比赛 11003

    我郁闷 交了第五次才过....
    第一次是CE........头文件乱七八糟混用 ....还自己声明了个与内部变量冲突的count.....
    后面的错误发现.....在大于180度需要减360的时候,我把弧度当角度了...=_=
    再后来本来要减360...我用360减了.....
    第五次AC...~~~
    不过比赛中这题就我们过了....nice~~~其实是一道水几何题.....
    #include<math.h>
    #include 
    <stdio.h>

    struct Point
    {
        
    double x;
        
    double y;
    }
    ;

    int n;
    Point came;
    Point point[
    50000];
    double agle;
    double ag;
    int cnt;



    double angel(double x,double y)
    {
        
    double c=sqrt(x*x+y*y);
        
    double d;
        
    if(x<=0)
        
    {
             d
    =360-acos(y/c)/(2*acos(-1.0))*360;
            
        }

        
    else
        
    {
            d
    = (acos(y/c))/(2*acos(-1.0))*360;
        }

        
    if(d>=360-(1e-7))
            
    return d-360;
        
    else
            
    return d;

    }



    int cacul(double a)
    {
        
    int cou=0;
        
    for(int i=0;i<n;i++)
        
    {
            
    double a1=angel((point[i].x-came.x), (point[i].y-came.y));
            
    double a2=a;
            
    if(a1-a2>180.0)
                a1
    =a1-360.0;
            
    if(a2-a1>180.0)
                a2
    =a2-360.0;
            
    if( (a1-a2>=0.0 && a1-a2<agle/2.0|| (a2-a1>=0.0 && a2-a1<agle/2.0))
                cou
    ++;
        }

        
    return cou;
    }


    void func()
    {
        cnt 
    = 0;
        
    double a=0.0;
        
    while(a<=3599)
        
    {
            
    int hold=cacul(a/10.0);
            
    if(cnt<hold)
            
    {
                cnt
    =hold;
                ag
    =a/10.0;
            }

            a
    +=1;
        }

    }



    int main()
    {
        
    while(scanf("%d",&n)!=EOF)
        
    {
            
    if(n==0)
                
    break;
            scanf(
    "%lf%lf%lf"&came.x, &came.y, &agle);
            
    for(int i=0;i<n;i++)
                scanf(
    "%lf%lf"&point[i].x, &point[i].y);
            func();
            printf(
    "Point the camera at angle %.1lf to view %d infested trees.\n", ag, cnt);
        }

        
    return 0;
    }
  • 相关阅读:
    项目管理基本目录结构
    Linux 杀死所有进程
    PHP生成唯一固定长度邀请码
    ubuntu LNMP环境下安装Redis,以及php的redis扩展
    Ubuntu linux 返回上一次访问的目录
    ubuntu删除ppa源
    ubuntu1.8安装lnmp失败
    phpstorm更改sql文件匹配类型
    小程序组件概述
    小程序中WXSS样式控制
  • 原文地址:https://www.cnblogs.com/SQL/p/892952.html
Copyright © 2011-2022 走看看