Tell me the area---hdu1798 (数学 几何)

http://acm.hdu.edu.cn/showproblem.php?pid=1798

给你两个圆求阴影部分的面积

求出两个扇形的面积减去四边形的面积

扇形的面积是度数(弧度制)*半径的平方

不能用PI 3.1415926   要用acos(-1.0);

求四边形面积就是两个三角形   用海伦公式

因为精确度比较高   所以就不能用PI 3.1415926

#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <math.h>

using namespace std;
#define memset(a,b) memset(a,b,sizeof(a))
#define N 1100000
typedef long long  ll;
#define PI 3.1415926

int main()
{
    double x1,y1,r1,x2,y2,r2;
    while(scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&r1,&x2,&y2,&r2)!=EOF)
    {
        double rr=min(r1,r2);
        double l=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
        if(l>=r1+r2)
        {
            printf("0.000\n");
            continue;
        }
        else if(l<=fabs(r1-r2))
        {

            printf("%.3lf\n",acos(-1.0)*rr*rr);
            continue;
        }
        double cos1=(r1*r1+l*l-r2*r2)/(2.0*r1*l);
        double cos2=(r2*r2+l*l-r1*r1)/(2.0*r2*l);

        double ss1=r1*acos(cos1)*r1;///r1扇形的面积
        double ss2=r2*acos(cos2)*r2;
        double p=(r1+r2+l)/2.0;///
        double S=2*sqrt(p*(p-r1)*(p-r2)*(p-l));///四边形的面积
        printf("%.3lf\n",ss1+ss2-S);
    }
    return 0;
}
时间: 2024-12-17 19:40:52

Tell me the area---hdu1798 (数学 几何)的相关文章

hdu 1115 Lifting the Stone (数学几何)

Lifting the Stone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5203    Accepted Submission(s): 2155 Problem Description There are many secret openings in the floor which are covered by a big

hdu 1577 WisKey的眼神 (数学几何)

WisKey的眼神 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2059    Accepted Submission(s): 625 Problem Description WisKey的眼镜有500多度,所以眼神不大好,而且他有个习惯,就是走路喜欢看着地(不是为了拣钱哦^_^),所以大家下次碰见他的时候最好主动打下招呼,呵呵.但是

POJ 题目1106 Transmitters(数学几何)

Transmitters Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4756   Accepted: 2538 Description In a wireless network with multiple transmitters sending on the same frequencies, it is often a requirement that signals don't overlap, or at

ACM: FZU 2110 Star - 数学几何 - 水题

FZU 2110  Star Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Practice Description Overpower often go to the playground with classmates. They play and chat on the playground. One day, there are a lot of stars in the sky.

Gym 101334A Area 51 数学

大致题意: 给出n个建筑的二维坐标,每个建筑名称为一个字母,不同坐标的建筑可以有同一名称,并保证这些坐标都是在y轴上半轴.给出一串建筑名称的字符串,在X轴上找出一个或多个区间,使Nick在这个区间上从左往右观看,看到的建筑顺序与给出的字符串相符合. 分析: 建筑物的数量最多100,那么我们可以先求出任意两点的连线与X轴的交点,每两个相邻的交点间的开区间看到的顺序是相同的.那么我们枚举所有区间即可. #include <iostream> #include <cstdio> #inc

poj2002 (极简单数学/几何+hash)

链接:http://poj.org/problem?id=2002 Squares Time Limit: 3500MS   Memory Limit: 65536K Total Submissions: 21720   Accepted: 8321 Description A square is a 4-sided polygon whose sides have equal length and adjacent sides form 90-degree angles. It is also

POJ 题目1905 Expanding Rods(二分,数学几何)

Expanding Rods Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 12827   Accepted: 3311 Description When a thin rod of length L is heated n degrees, it expands to a new length L'=(1+n*C)*L, where C is the coefficient of heat expansion. Whe

POJ 题目3305Surveillance(数学几何,三分)

Surveillance Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 274   Accepted: 92 Description See.Eye.A, the world's biggest independent intelligence agency, is located in a very large underground building. Recently, due to the large amoun

hdu 6097 Mindis(数学几何,圆心的反演点)

Mindis Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2787    Accepted Submission(s): 555Special Judge Problem Description The center coordinate of the circle C is O, the coordinate of O is (0,