两个圆环的内外径相同 给出内外径 和 两个圆心 求两个圆环相交的面积

画下图可以知道 就是两个大圆交-2*小圆与大圆交+2小圆交

Sample Input
2
2 3
0 0
0 0
2 3
0 0
5 0

Sample Output
Case #1: 15.707963
Case #2: 2.250778

 # include <iostream>
# include <cstdio>
# include <cstring>
# include <algorithm>
# include <string>
# include <cmath>
# include <queue>
# include <list>
# define LL long long
using namespace std ; const double eps = 1e-;
const double PI = acos(-1.0); struct Point
{
double x,y;
Point(){}
Point(double _x,double _y)
{
x = _x;y = _y;
}
Point operator -(const Point &b)const
{
return Point(x - b.x,y - b.y);
}
//叉积
double operator ^(const Point &b)const
{
return x*b.y - y*b.x;
}
//点积
double operator *(const Point &b)const
{
return x*b.x + y*b.y;
}
//绕原点旋转角度B(弧度值),后x,y的变化
void transXY(double B)
{
double tx = x,ty = y;
x = tx*cos(B) - ty*sin(B);
y = tx*sin(B) + ty*cos(B);
}
}; //*两点间距离
double dist(Point a,Point b)
{
return sqrt((a-b)*(a-b));
} //两个圆的公共部分面积
double Area_of_overlap(Point c1,double r1,Point c2,double r2)
{
double d = dist(c1,c2);
if(r1 + r2 < d + eps)return ;
if(d < fabs(r1 - r2) + eps)
{
double r = min(r1,r2);
return PI*r*r;
}
double x = (d*d + r1*r1 - r2*r2)/(*d);
double t1 = acos(x / r1);
double t2 = acos((d - x)/r2);
return r1*r1*t1 + r2*r2*t2 - d*r1*sin(t1);
} int main()
{
//freopen("in.txt","r",stdin) ;
int T ;
scanf("%d" , &T) ;
int Case = ;
while(T--)
{
Case++ ;
double r , R ;
double x1 , y1 , x2 , y2 ;
scanf("%lf%lf%lf%lf%lf%lf" , &r , &R , &x1 , &y1 , &x2 , &y2) ;
Point c1(x1 ,y1) ;
Point c2(x2 ,y2) ;
double ans = ;
ans = Area_of_overlap(c1,R,c2,R) + Area_of_overlap(c1,r,c2,r);
ans -= Area_of_overlap(c1,r,c2,R) ;
ans -= Area_of_overlap(c1,R,c2,r) ;
printf("Case #%d: %.6lf\n" , Case , ans) ; }
return ;
}

hdu 5120(求两个圆环相交的面积 2014北京现场赛 I题)的更多相关文章

  1. hdu 5112 (2014北京现场赛 A题)

    给出某个时刻对应的速度 求出相邻时刻的平均速度 输出最大值 Sample Input23 // n2 2 //t v1 13 430 31 52 0 Sample OutputCase #1: 2.0 ...

  2. hdu 5122 (2014北京现场赛 K题)

    把一个序列按从小到大排序 要执行多少次操作 只需要从右往左统计,并且不断更新最小值,若当前数为最小值,则将最小值更新为当前数,否则sum+1 Sample Input255 4 3 2 155 1 2 ...

  3. hdu 5120 (求两圆相交的面积

    题意:告诉你两个圆环,求圆环相交的面积. /* gyt Live up to every day */ #include<cstdio> #include<cmath> #in ...

  4. hdu 5071(2014鞍山现场赛B题,大模拟)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5071 思路:模拟题,没啥可说的,移动的时候需要注意top的变化. #include <iostr ...

  5. hdu 5078 2014鞍山现场赛 水题

    http://acm.hdu.edu.cn/showproblem.php?pid=5078 现场最水的一道题 连排序都不用,由于说了ti<ti+1 //#pragma comment(link ...

  6. hdu 5078(2014鞍山现场赛 I题)

    数据 表示每次到达某个位置的坐标和时间 计算出每对相邻点之间转移的速度(两点间距离距离/相隔时间) 输出最大值 Sample Input252 1 9//t x y3 7 25 9 06 6 37 6 ...

  7. hdu 5137 去掉一个点 使得最短路最大(2014广州现场赛 K题)

    题意:从2~n-1这几个点中任意去掉一个点,使得从1到n的最短路径最大,如果任意去掉一个点1~n无通路输出Inf. Sample Input4 51 2 31 3 71 4 502 3 43 4 23 ...

  8. hdu 5131 (2014广州现场赛 E题)

    题意:对给出的好汉按杀敌数从大到小排序,若相等,按字典序排.M个询问,询问名字输出对应的主排名和次排名.(排序之后)主排名是在该名字前比他杀敌数多的人的个数加1,次排名是该名字前和他杀敌数相等的人的个 ...

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

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

随机推荐

  1. pyqt4_应用例子(计算器,对话框,进度条,日历等等)

    sklearn实战-乳腺癌细胞数据挖掘(博客主亲自录制视频教程) https://study.163.com/course/introduction.htm?courseId=1005269003&a ...

  2. 开始 Dojo 开发

    原文出处:Joe Lennon 从头开始学习 Dojo,第 1 部分 开始 Dojo 开发 Dojo Toolkit 简介 Dojo 于 2004 年创建,使开发 DHTML 和 JavaScript ...

  3. Date时间格式比较大小

    方法一: 两个Date类型的变量可以通过compareTo方法来比较.此方法的描述是这样的:如果参数 Date 等于此 Date,则返回值 0:如果此 Date 在 Date 参数之前,则返回小于 0 ...

  4. CF&&CC百套计划2 CodeChef December Challenge 2017 Chef And his Cake

    https://www.codechef.com/DEC17/problems/GIT01 #include<cstdio> #include<algorithm> using ...

  5. Python json转字符串的一些细节

    要调PHP那边的接口,php那边一直都校验不过,很是郁闷.没办法,只能让人把发送成功的代码拿过来看,不过是php写的,步骤都是一样: php端: 1. json对象转json字符串. 2. 对json ...

  6. [译]Quartz.NET 框架 教程(中文版)2.2.x 之第五课 SimpleTrigger

    第五课 SimpleTrigger 如果你需要在一个指定时间段内执行一次作业任务或是在指定的时间间隔内多次执行作业任务,SimpleTrigger应该能满足你的调度需求.例如,你希望触发器在2015年 ...

  7. Twitter.com在用哪些Javascript框架?

    我一直在研究 twitter.com 使用的一些 UI 框架.下面是这些框架的清单(大部分是 Javascript 框架).如果你发现有些框架 Twitter 已经没在使用了,请随时告诉我! 测试 J ...

  8. java 去除末尾的零 如果小数点可以去除同时去除小数点

    String s; if(s.indexOf(".") > 0){ //正则表达 s = s.replaceAll("0+?$", "" ...

  9. util.promisify 的那些事儿

    util.promisify是在node.js 8.x版本中新增的一个工具,用于将老式的Error first callback转换为Promise对象,让老项目改造变得更为轻松. 在官方推出这个工具 ...

  10. halcon发布

    1: halcon发布 : 在MFC程序中 添加 #include "include/halcon/cpp/HalconCpp.h"using namespace Halcon;# ...