1118 - Incredible Molecules
Time Limit: 0.5 second(s) Memory Limit: 32 MB

In the biological lab, you were examining some of the molecules. You got some interesting behavior about some of the molecules. There are some circular molecules, when two of them collide, they overlap with each other, and it's hard to find that which one is over the other one.

Given two molecules as circles, you have to find the common area of the given molecules that is shaded in the picture.

Overlapping Molecules

Input

Input starts with an integer T (≤ 12), denoting the number of test cases.

Each case contains six integers x1, y1, r1 and x2, y2, r2. Where (x1, y1) is the center of the first molecule and r1 is the radius and (x2, y2) is the center of the second molecule and r2 is the radius. Both the radiuses are positive. No integer will contain more than 3 digits.

Output

For each test case, print the case number and the common area of the given molecules. Errors less than 10-6 will be ignored.

Sample Input

Output for Sample Input

3

0 0 10 15 0 10

-10 -10 5 0 -10 10

100 100 20 100 110 20

Case 1: 45.3311753978

Case 2: 35.07666099

Case 3: 860.84369

http://lightoj.com/volume_showproblem.php?problem=1118

很简单,作为模板了

 /* ***********************************************
Author :kuangbin
Created Time :2013-10-15 18:56:20
File Name :E:\2013ACM\专题强化训练\计算几何\LightOJ1118.cpp
************************************************ */ #include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std; const double eps = 1e-;
const double PI = acos(-1.0);
struct Point
{
double x,y;
void input()
{
scanf("%lf%lf",&x,&y);
}
};
double dist(Point a,Point b)
{
return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
//两个圆的公共部分面积
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);
//freopen("out.txt","w",stdout);
Point c1,c2;
double r1,r2;
int T;
scanf("%d",&T);
int iCase = ;
while(T--)
{
iCase ++;
c1.input();
scanf("%lf",&r1);
c2.input();
scanf("%lf",&r2);
printf("Case %d: %.6lf\n",iCase,Area_of_overlap(c1,r1,c2,r2));
}
return ;
}

LightOJ 1118 - Incredible Molecules (两圆面积交)的更多相关文章

  1. LightOj 1118 - Incredible Molecules(两圆的交集面积)

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1118 给你两个圆的半径和圆心,求交集的面积: 就是简单数学题,但是要注意acos得到的 ...

  2. LightOJ 1118--Incredible Molecules(两圆相交)

    1118 - Incredible Molecules      PDF (English) Statistics Forum Time Limit: 0.5 second(s) Memory Lim ...

  3. zstuoj 4243 牛吃草 ——(二分+两圆交)

    这题上次补了以后忘记写博客了,现在补一下. 有两个注意点,第一是两圆相交的模板.可以通过任意一种情况手推出来. 第二是,实数二分要注意不用ans记录为妙,因为可能因为eps过小,导致ans无法进入记录 ...

  4. 西南民大oj(两园交求面积)

    西南民大oj:http://www.swunacm.com/acmhome/welcome.do?method=index 我的几何不可能那么可爱 时间限制(普通/Java) : 1000 MS/ 3 ...

  5. 【TOJ 1449】Area of Circles II(求不同位置的两圆面积之和)

    描述 There are two circles on the plane. Now you must to calculate the area which they cover the plane ...

  6. lightoj 1293 - Document Analyzer [ 两指针 + 字符串 ]

    传送门 1293 - Document Analyzer   PDF (English) Statistics Forum Time Limit: 3 second(s) Memory Limit: ...

  7. [hdu 3264] Open-air shopping malls(二分+两圆相交面积)

    题目大意是:先给你一些圆,你可以任选这些圆中的一个圆点作圆,这个圆的要求是:你画完以后.这个圆要可以覆盖之前给出的每一个圆一半以上的面积,即覆盖1/2以上每一个圆的面积. 比如例子数据,选左边还是选右 ...

  8. 2014年亚洲区域赛北京赛区现场赛A,D,H,I,K题解(hdu5112,5115,5119,5220,5122)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud 下午在HDU上打了一下今年北京区域赛的重现,过了5题,看来单挑只能拿拿铜牌,呜呜. ...

  9. HZNU ACM一日游 2019.3.17 【2,4,6-三硝基甲苯(TNT)】

    Travel Diary 早上8:00到HG,听说hjc20032003在等我. 然后他竟然鸽我...最后还是勉强在8:30坐上去偏僻的HZNU的地铁. 到文新,然后带上fjl,打滴滴,一行人来到了H ...

随机推荐

  1. c++刷题(30/100)

    题目一:合并两个排序的链表 输入两个单调递增的链表,输出两个链表合成后的链表,当然我们需要合成后的链表满足单调不减规则. 思路:利用两个指针cur1,cur2来指分别向两个链表中当前较小的和当前较大的 ...

  2. Ubuntu GNOME单击任务栏图标最小化设置

    在Ubuntu GNOME的发行版中,桌面使用的是GNOME,GNOME可以像Windows那样有一个底部任务栏,在Ubuntu GNOME中它称为 dash to dock,如下图: Windows ...

  3. 【工具】用命令行与Python使用YARA规则

    1.前言 YARA是一款旨在帮助恶意软件研究人员识别和分类恶意软件样本的开源工具,使用YARA可以基于文本或二进制模式创建恶意软件家族描述与匹配信息.现在已经被多家公司所运用于自身的产品. 2.YAR ...

  4. 激活Window和office工具

    激活Window和office工具:    第一种工具(已使用工具激活microsoft office professional plus 2013版本):         暴风激活工具(暴风激活工具 ...

  5. kafka脚本

    为了便于使用,kafka提供了比较强大的Tools,把经常需要使用的整理一下 开关kafka Server bin/kafka-server-start.sh config/server.proper ...

  6. Carbon 的 diffForHumans 方法

    Carbon 是继承自 PHP DateTime 类 的子类,但比后者提供了更加丰富.更加语义化的 API.其中一个比较实用的 API 就是 diffForHumans 方法,几乎每个用 Larave ...

  7. KnockoutJs学习笔记(十二)

    value binding一般适用于input.select.textarea等form elements中,能够将view model中的属性和相关联的DOM element的值(value)连接起 ...

  8. adb shell 命令计算APP应用的 FPS 和评价流畅度。

    设计初衷: 1.面临用户和公司内领导试用中反馈的卡顿问题,思考如何能有效量化评估? 2.如何在尝试复现卡顿的过程中持续监控FPS和丢帧情况? 操作说明如下: (1)脚本源码的下载:(https://p ...

  9. VMware虚拟机三种联网方法及原理

    VMware虚拟机三种联网方法及原理   一.Brigde——桥接:默认使用VMnet0   1.原理:   Bridge 桥"就是一个主机,这个机器拥有两块网卡,分别处于两个局域网中,同时 ...

  10. 关于spark ui中executor显示的内存量与设置的内存量不符的问题

    executor显示的内存量是实际执行程序使用的内存量,也就是排除bspark.storage.memoryFraction设置的比例外,然后使用的内存量. 默认是0.6,所以executory和dr ...