• 站军姿


    2bc*cosA=b^2+c^2-a^2

    /*
      先吐槽一下标程π的取值范围
      蒟蒻表示真没想到怎么求相交的情况,一心就想求交点,其实计算香蕉的面积
    
    可以用扇形减去三角形
    */
    #include<cstdio>
    #include<cstdlib>
    #include<cmath>
    #include<iostream>
    #include<algorithm>
    const double pi=3.14159265358979323846264;
    using namespace std;
    void work()
    {
        double x1,y1,r1,x2,y2,r2;
        scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&r1,&x2,&y2,&r2);
        double d=sqrt(abs(x1-x2)*abs(x1-x2)+abs(y1-y2)*abs(y1-y2));
        if(r1+r2<=d)//相离
        {
            double ans=r1*r1*pi+r2*r2*pi;
            printf("%.3lf
    ",ans);
            return;
        }
        if(r1+r2>d&&abs(r1-r2)>=d)//内含 
        {
            double ans=max(r2,r1)*max(r2,r1)*pi;
            printf("%.3lf
    ",ans);
            return;
        }
        //相交 
        double ans=r1*r1*pi+r2*r2*pi;
        double j1=acos((d*d+r1*r1-r2*r2)/(2*d*r1));
        double j2=acos((d*d+r2*r2-r1*r1)/(2*d*r2));
        ans-=(r1*r1*j1+r2*r2*j2);
        ans+=d*r1*sin(j1);
        printf("%.3lf
    ",ans);
    }
    int main()
    {
        freopen("jh.in","r",stdin);
        //freopen("standing.in","r",stdin);
        //freopen("standing.out","w",stdout);
        int T;scanf("%d",&T);
        while(T--)
        {
            work();
        }
        return 0;
    }
    View Code
  • 相关阅读:
    5、文件处理
    6、Python模块
    4、字典使用
    3、列表 list
    1、Python基础
    2、循环判断
    配置LOG4J(log4j-1.2.17)
    File /WEB-INF/web.xml not found...
    关于TOMCAT的 ROOT/WEB-INF/web.xml的配置
    tomcat 配置系列3
  • 原文地址:https://www.cnblogs.com/harden/p/5933057.html
Copyright © 2020-2023  润新知