Circular Area
                                                       Time Limit: 1000MS  Memory Limit: 65536K
 

Description

Your task is to write a program, which, given two circles, calculates the area of their intersection with the accuracy of three digits after decimal point.

Input

In the single line of input file there are space-separated real numbers x1 y1 r1 x2 y2 r2. They represent center coordinates and radii of two circles.

Output

The output file must contain single real number - the area.

Sample Input

20.0 30.0 15.0 40.0 30.0 30.0

Sample Output

608.366

Source

Northeastern Europe 2000, Far-Eastern Subregion
 
 
这道题直接上模板就可以了~
 
模板:
 
struct Circle{
double x, y, r;
};
//圆的圆心坐标,半径 double dis(Circle a, Circle b){
return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
//两圆圆心的距离 double solve(Circle a, Circle b){
double d = dis(a, b);
if (d >= a.r + b.r) return ;
if (d <= fabs(a.r - b.r)){
double r = a.r < b.r ? a.r : b.r;
return pi * r * r;
} double ang1 = acos((a.r * a.r + d * d - b.r * b.r) / 2.00 / a.r / d);
double ang2 = acos((b.r * b.r + d * d - a.r * a.r) / 2.00 / b.r / d);
double ret = ang1 * a.r * a.r + ang2 * b.r * b.r - d * a.r * sin(ang1);
return ret;
}
//返回值即为两圆公共部分的面积
 
 
POJ2546:
 #include <bits/stdc++.h>

 using namespace std;

 #define pi    3.1415926535897932384626

 struct Circle{
double x, y, r;
} r[]; double dis(Circle a, Circle b){
return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
} double solve(Circle a, Circle b){
double d = dis(a, b);
if (d >= a.r + b.r) return ;
if (d <= fabs(a.r - b.r)){
double r = a.r < b.r ? a.r : b.r;
return pi * r * r;
} double ang1 = acos((a.r * a.r + d * d - b.r * b.r) / 2.00 / a.r / d);
double ang2 = acos((b.r * b.r + d * d - a.r * a.r) / 2.00 / b.r / d);
double ret = ang1 * a.r * a.r + ang2 * b.r * b.r - d * a.r * sin(ang1);
return ret;
} int main(){ while (~scanf("%lf%lf%lf%lf%lf%lf", &r[].x, &r[].y, &r[].r, &r[].x, &r[].y, &r[].r))
printf("%.3f\n", solve(r[], r[])); return ; }

POJ2546 Circular Area(计算几何)的更多相关文章

  1. 【poj2546】 Circular Area

    http://poj.org/problem?id=2546 (题目链接) 题意 求两圆的面积交 Solution 一道水题Wa死我了,肯定是昨晚搞太晚的缘故= =. 两圆的位置关系有5种,而这里要求 ...

  2. POJ 1654 Area 计算几何

    #include<stdio.h> #include<string.h> #include<iostream> #include<math.h> usi ...

  3. [ZOJ 1010] Area (计算几何)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1010 题目大意:给你n个点,问你顺次连线能否连成多边形?如果能, ...

  4. POJ 2546 &amp; ZOJ 1597 Circular Area(求两圆相交的面积 模板)

    题目链接: POJ:http://poj.org/problem? id=2546 ZOJ:problemId=597" target="_blank">http: ...

  5. Hdu-2892 area 计算几何 圆与凸多边形面积交

    题面 题意:有一个凸多边形岛屿,然后告诉你从高空(x,y,h)投下炸弹,爆炸半径r,飞机水平速度和重力加速度,问岛屿被炸了多少 题解:算出来岛屿落地位置,再利用圆与凸多边形面积交 #include&l ...

  6. POJ 2546 Circular Area(两个圆相交的面积)

    题目链接 题意 : 给你两个圆的半径和圆心,让你求两个圆相交的面积大小. 思路 : 分三种情况讨论 假设半径小的圆为c1,半径大的圆为c2. c1的半径r1,圆心坐标(x1,y1).c2的半径r2,圆 ...

  7. UVa 1641 ASCII Area (计算几何,水题)

    题意:给定一个矩阵,里面有一个多边形,求多边形的面积. 析:因为是在格子里,并且这个多边形是很规则的,所以所有格子不是全属于多边形就是全不属于,或者一半,并且我们可以根据"/"和“ ...

  8. POJ 2546 Circular Area 几何

    http://poj.org/problem?id=2546 晚上发现鼠标快不行了了!!!鼠标你肿么了,肿么突然就按键不灵了,哭,谁送我一只呀,奖励我舍友一只.哈哈.开玩笑滴~ 舍友大怒说" ...

  9. Maltego实体分类与Transform

    分类 实体类型 描述 Devices (设备类) Device 表示一个设备,如一个手机或相机. Infrastructure (基础结构类) AS 一个互联网自治系统   DNS Name 域名系统 ...

随机推荐

  1. 递推:Number Sequence(mod找规律)

    解题心得: 1.对于数据很大,很可怕,不可能用常规手段算出最后的值在进行mod的时候,可以思考找规律. 2.找规律时不必用手算(我傻,用手算了好久).直接先找前100项进行mod打一个表出来,直接看就 ...

  2. Android Kotlin适用小函数

    都是一些Android适用的Kotlin小函数. 1.点击空白隐藏键盘 //点击空白隐藏键盘 override fun onTouchEvent(event: MotionEvent): Boolea ...

  3. np.newaxis()用法

    这个是liaspace函数 这个是np.newaxis的用法,增加维度,写一个表示增加一维,两个表示增加2维2位置的:号是对a的取值范围,如果把np.newaxis作为第一个参数是对行增加维度,作为第 ...

  4. _cdecl _stdcall

    __cdecl程序的压栈方式为C风格__stdcall为PASCAL风格 举个例子:(1)   C函数  Fun1(a,b,c)   函数调用时,参数压栈顺序为 c , b , a(2)   PASC ...

  5. 用户注册,登录API 接口

    Controer: <?php /** * @name UserController * @author pangee * @desc 用户控制器 */ class UserController ...

  6. Http请求连接池-HttpClient的AbstractConnPool源码分析

    在做服务化拆分的时候,若不是性能要求特别高的场景,我们一般对外暴露Http服务.Spring里提供了一个模板类RestTemplate,通过配置RestTemplate,我们可以快速地访问外部的Htt ...

  7. web访问流程

    客户端发送请求—->httpd得到请求—->httpd解析请求的格式(html,css,jsp)—->请求相应的PHP解析—->PHP解析程序执行完毕—–>db(数据库) ...

  8. [报错处理]Could not find a version that satisfies the requirement xml (from versions)

    安装xml库发生报错 pip3 install xml Collecting xml Could not find a version that satisfies the requirement x ...

  9. getRequestURI,getRequestURL的区别,获取各种路径的方法

    getRequestURI,getRequestURL的区别 test1.jsp======================= <a href ="test.jsp?p=fuck&qu ...

  10. Unity属性——AddComponentMenu

    字面理解:添加 组件选项菜单 分析:可能是添加一个脚本或者组件到一个物体上 验证: 新建一个脚本:AttributeTest 提示:添加一个组件菜单属性,允许你放一个脚本在Compoent菜单下,来代 ...