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. sql中保留一位小数的百分比字符串拼接,替换函数,换行符使用

    select  num ,cast(round(convert(float,isnull((a.Sum_Num-d.Sum_Num),0))/convert(float,c.Sum_Store_Num ...

  2. visual studio 2010 自带reporting报表本地加载的使用

    原文:visual studio 2010 自带reporting报表本地加载的使用 在这家公司时间不长,接触都是之前没玩过的东东,先是工作流引擎和各种邮件短信的审核信息,后又是部署reporting ...

  3. golang echo livereload

    echo on port 1323 gin -a 1323 run server.go go get github.com/codegangsta/gin gin -h

  4. tomcat内存泄漏存入dump文件

    很多tomcat进程退出(或者进程假死),都是由于频繁的抛出OutOfMemeoryError导致的. 为了让tomcat退出前或者发生OutOfMemeoryError时自动dump堆栈信息,方便事 ...

  5. Careercup - Microsoft面试题 - 5672369481842688

    2014-05-12 06:27 题目链接 原题: Find the max height of a binary tree. 题目:计算二叉树的最大高度. 解法:最大高度?高度不就是最深的叶子节点到 ...

  6. 踩坑 Uncaught RangeError: Maximum call stack size exceeded

    今天遇到了一个错误, 堆栈溢出,很好奇就是一个简单ajax请求怎么会报这个错误,研究了一下,发现犯了一个很低级的错误,data的参数错误了: passWord是未定义的变量,值为空,然后导致了这个问题 ...

  7. PAT——乙级1026and1046

    1026 程序运行时间 (15 point(s)) 要获得一个 C 语言程序的运行时间,常用的方法是调用头文件 time.h,其中提供了 clock() 函数,可以捕捉从程序开始运行到 clock() ...

  8. html之表单标签

    表单标签的属性: 用于向服务器传输数据 表单能够包含input元素,比如文本字段,复选框,单选框,提交按钮等等 表单还可以包含textarea(简介之类的),select(下拉),fieldset和l ...

  9. tomcat源码分析一

    废话少说,拉代码,导入eclipse开干,具体步骤可以参考http://hi.baidu.com/hateeyes/blog/item/7f44942a20ad8f9d023bf66d.html 下面 ...

  10. PAT1038(两个运行超时 未解决

    # include<iostream> # include<algorithm> using namespace std; int jishu(int a[],int N,in ...