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. UVA1484 Alice and Bob's Trip (hdu3660)

    一.前言 最开始卡这题是某大佬给出的树DP专题中的一个,据说类似于对抗搜索(这是啥?)的一题 但是在经历了若干艰难困苦之后发现这题在HDU上A不了——(先卡vector的时间,后卡输入的时间,上了输入 ...

  2. Hive UDTF开发指南

    在这篇文章中,我们将深入了解用户定义表函数(UDTF),该函数的实现是通过继承org.apache.Hadoop.hive.ql.udf.generic.GenericUDTF这个抽象通用类,UDTF ...

  3. laravel5.2总结--redis使用

    一切的前提都是已经安装好了redis服务器,并且能启动(我只总结了mac的安装方法:传送门) 我自己使用的是mac系统,有个教程可以参考下,传送门: 1.安装PHP PRedis 1>PRedi ...

  4. 可拖动jquery插件

    http://www.open-open.com/ajax/DragDrop.htm http://sc.chinaz.com/info/130722592854.htm http://sc.itcn ...

  5. POJ 3686 The Windy's(思维+费用流好题)

    The Windy's Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 5362   Accepted: 2249 Descr ...

  6. [SDOI2011][bzoj2286] 消耗战 [虚树+dp]

    题面: 传送门 思路: 看到所有询问中的点数总和是十万级别的,就想到用虚树~\(≧▽≦)/~啦 首先,树形dp应该是很明显可以看出来的: 设dp[u]表示以u为根的子树(不包括u)中的宝藏岛全部切断的 ...

  7. Codeforces Round #323 (Div. 2) A 水

    A. Asphalting Roads time limit per test 1 second memory limit per test 256 megabytes input standard ...

  8. java读取文件的基本操作

    import java.io.FileInputStream; /** * 使用FileInputStream读取文件 */ public class FileRead { /** * @param ...

  9. css 文字垂直居中问题

    CSS 文字垂直居中问题 问题:在 div 中文字居中问题: 当使用 line-height:100%%; 时,文字没有居中,如下: html: <div id="header_log ...

  10. 解决 unity 用 vs通过wifi 真机联调 一直连接不上

    平时 在公司网络太差,要通过wifi 用vs真机联调时,vs一直连不上设备,很是蛋疼...用下面官方给出的方法可以解决 Attaching MonoDevelop Debugger To An And ...