• Sicily 1698. Hungry Cow


    几何题

    题意:题意不详说了,易懂,就是算面积,比较简单的题目

    分四种情况讨论即可

    1.不会碰到木板

    2.不会饶过木板,但是碰到(相当于一个圆被切掉了下面一小部分)

    3.绕过木板,在下方形成一个两个小圆

    4.两个小圆会重叠,减去重叠的部分

    匆匆忙忙写的代码,很乱,懒得修改了

    #include <cstdio>
    #include <cstring>
    #include <cmath>
    
    const double PI = acos(-1);
    const double E = 1e-9;
    
    double L,D,S,SS;
    double a,b,oo;
    double v1,v2,v3,v4;
    
    int main()
    {
       int T;
       scanf("%d",&T);
       while(T--)
       {
          scanf("%lf%lf%lf",&L,&D,&S);
          if( S<=D )
          {
             printf("%.2lf\n", PI*S*S);
             continue;
          }
          else if( S > sqrt((L/2)*(L/2)+D*D) )
          {
             a = 2*atan((L/2)/D);
             oo = 2*PI - a;
             b = PI - (PI/2-a/2);
             v1 = PI*S*S - S*S*a/2;
             SS = S - sqrt( (L/2)*(L/2) + D*D);
             v2 = SS*SS*b/2;
             v3 = 0.5*L*D;
             if(SS > L/2)  //重复部分
             {
                double c = 2*acos((L/2)/SS);
                double LL = 2*sqrt(SS*SS-(L/2)*(L/2));
                v4 = SS*SS*c/2 - 0.5*LL*(L/2);
                printf("%.2lf\n", v1 + 2*v2 + v3 - v4);
             }
             else printf("%.2lf\n", v1 + 2*v2 + v3);
          }
          else
          {
             a = 2*acos(D/S);
             oo = 2*PI - a;
             v1 = PI*S*S - S*S*a/2;
             double LL = 2*sqrt(S*S - D*D);
             v2 = 0.5 * D * LL;
             printf("%.2lf\n",v1+v2);
          }
       }
       return 0;
    }
  • 相关阅读:
    哪怕我变成一个庸俗女子
    硬盘接口的种类
    HTTPS与SHTTP
    Jquery动态加载页面
    iText简介
    TFS offline issue
    VS2008 调试慢的问题
    One error related to msxml4.dll (0x800C0014)
    46 Run Commands for Frequently Used Areas of Your Windows Computer
    快速启动工具入门——以Launchy为例(二)
  • 原文地址:https://www.cnblogs.com/scau20110726/p/3065438.html
Copyright © 2020-2023  润新知