A - A

Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu

Description

Agent J is preparing to steal an antique diamond piece from a museum. As it is fully guarded and they are guarding it using high technologies, it's not easy to steal the piece. There are three circular laser scanners in the museum which are the main headache for Agent J. The scanners are centered in a certain position, and they keep rotating maintaining a certain radius. And they are placed such that their coverage areas touch each other as shown in the picture below:

Here R1R2 and R3 are the radii of the coverage areas of the three laser scanners. The diamond is placed in the place blue shaded region as in the picture. Now your task is to find the area of this region for Agent J, as he needs to know where he should land to steal the diamond.

Input

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

Each case starts with a line containing three real numbers denoting R1, R2 and R3 (0 < R1, R2, R3 ≤ 100). And no number contains more than two digits after the decimal point.

Output

For each case, print the case number and the area of the place where the diamond piece is located. Error less than 10-6 will be ignored.

Sample Input

3

1.0 1.0 1.0

2 2 2

3 3 3

Sample Output

Case 1: 0.16125448

Case 2: 0.645017923

Case 3: 1.4512903270

题解:

求三个圆围成的区域面积,注意要用acos,asin会出错,因为sin150 = 1/2, sin30 = 1/2;这样asin就出错了。。

代码:

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
template<typename T, typename T1>
T getcos(T1 a, T b, T c){
return (b*b + c*c - a*a) / (*b*c);
}
template<typename T>
T Angarea(T a, T b, T c){
return 0.5 * b * c * sin(a);
}
template<typename T>
T cirarea(T a, T r){
return 0.5 * a * r * r;
} int main(){
int T;
double r1, r2, r3;
int kase = ;
scanf("%d", &T);
while(T--){
scanf("%lf%lf%lf", &r1, &r2, &r3);
double cosa = getcos(r2 + r3, r1 + r2, r1 + r3);
double cosb = getcos(r1 + r2, r2 + r3, r1 + r3);
double cosc = getcos(r1 + r3, r1 + r2, r2 + r3);
double a = acos(cosa);
double b = acos(cosb);
double c = acos(cosc);
double ans = Angarea(a, r1 + r2, r1 + r3) - cirarea(a, r1) - cirarea(b, r3) - cirarea(c, r2);
printf("Case %d: %lf\n", ++kase, ans); }
return ;
}
 

Agent J(求三个圆围成的区域面积)的更多相关文章

  1. HDU 1071 The area(求三个点确定的抛物线的面积,其中一个点是顶点)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1071 The area Time Limit: 2000/1000 MS (Java/Others)  ...

  2. 求曲线y=lnx在区间(2,6)内的一条切线,使得该切线与直线x=2,x=6及曲线y=lnx所围成的图形的面积最小。

    求曲线y=lnx在区间(2,6)内的一条切线,使得该切线与直线x=2,x=6及曲线y=lnx所围成的图形的面积最小. 1.先画图. 2.设切点为(a,lna) (2<a<6) 3.切线方程 ...

  3. uva11178 Morley’s Theorem(求三角形的角三分线围成三角形的点)

    Morley’s Theorem Input: Standard Input Output: Standard Output Morley’s theorem states that that the ...

  4. 多个n维向量围成的n维体积的大小

    前言 上周我们数学老师给了我们一道题,大意就是两个向量a和b,一个点M=$x*a+y*b$,x,y有范围,然后所有M组成的面积是一个定值,求x+y的最小值.当然这是道小水题,但我在想,如果把两个向量变 ...

  5. CodeForces 8D Two Friends 判断三个圆相交

    题意: 有两个人\(Alan\)和\(Bob\),他们现在都在\(A\)点,现在\(Bob\)想去\(B\)点,\(Alan\)想先到\(C\)点再去\(B\)点. \(Alan\)所走的总路程不能超 ...

  6. LeetCode 85 | 如何从矩阵当中找到数字围成的最大矩形的面积?

    本文始发于个人公众号:TechFlow,原创不易,求个关注 今天是LeetCode专题53篇文章,我们一起来看看LeetCode中的85题,Maximal Rectangle(最大面积矩形). 今天的 ...

  7. HDU 3467 (求五个圆相交面积) Song of the Siren

    还没开始写题解我就已经内牛满面了,从晚饭搞到现在,WA得我都快哭了呢 题意: 在DotA中,你现在1V5,但是你的英雄有一个半径为r的眩晕技能,已知敌方五个英雄的坐标,问能否将该技能投放到一个合适的位 ...

  8. codeforces 8D Two Friends 二分+ 判断三个圆是否有公共交点

    题目链接 有两个人x, y, 现在在A点, x要直接去B点, y要先去C点在去B点, 现在给出x, y两人可以行走的最大距离T1, T2, 求出他们从A点出发之后, 可以走的最长的公共路径. 我们先看 ...

  9. poj3819 Coverage (求直线与圆的交占直线的百分比 )

    题意:给你一条直线和若干个圆,求圆与直线相交的长度占整条直线的比例 解题思路:通过定比分点的方法求出圆与直线的交占圆的比例. 第一步:(确定投影的方向是x轴还是y轴) (1)当直线的line.s(x, ...

随机推荐

  1. pyQt事件处理

    Qt事件处理01 Qt处理事件的第二种方式:"重新实现QObject::event()函数",通过重新实现event()函数,可以在事件到达特定的事件处理器之前截获并处理他们.这种 ...

  2. pyqt tabWidget例子学习1

    from PyQt4 import QtGui from PyQt4 import QtCore from PyQt4.QtCore import pyqtSlot,SIGNAL,SLOT impor ...

  3. 地下迷宫(bfs输出路径)

    题解:开一个pre数组用编号代替当前位置,编号用结构题另存,其实也可以i*m+j来代替,我写的有点麻烦了; 代码: #include <iostream> #include <cst ...

  4. Jpeg(模拟)

    Jpeg Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status  ...

  5. java与.net比较学习系列(4) 运算符和表达式

    上一篇总结了java的数据类型,得到了冰麟轻武等兄弟的支持,他们提出并补充了非常好的建议,在这里向他们表示感谢.在后面的文章中,我会尽力写得更准确和更完善的,加油! 另外,因为C#是在java之后,也 ...

  6. 观察者模式与Boost.Signals

      1)  观察者模式定义 略,各种设计模式的书上都有定义. 2)  观察者模式一般实现 观察者模式一般实现,都是“被观察者”保存一个“观察者”的列表,循环这个列表来通知“观察者”.代码,其中使用了b ...

  7. [HeadFirst-HTMLCSS学习笔记][第十四章交互活动]

    表单 <form action="http://wickedlysmart.com/hfhtmlcss/contest.php" method="POST" ...

  8. LANMP 一键下载

    下载安装 wget http://dl.wdlinux.cn:5180/lanmp_v2.5.tar.gz tar zxvf lanmp_v2.5.tar.gz sh install.sh 4个可选安 ...

  9. commit后数据库干的工作

    用户提交commit后,数据库干的工作有: 1,oracle为用户的transaction生成一个SCN号. 2,LGWR把redo buffer中的数据写入到redo log file,同时把SCN ...

  10. VS C# 嵌入互操作类型

    SQLDMO.Restore oRestore = new SQLDMO.RestoreClass(); SQLDMO.SQLServer oSQLServer = new SQLDMO.SQLSer ...