Agent J(求三个圆围成的区域面积)
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 R1, R2 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(求三个圆围成的区域面积)的更多相关文章
- HDU 1071 The area(求三个点确定的抛物线的面积,其中一个点是顶点)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1071 The area Time Limit: 2000/1000 MS (Java/Others) ...
- 求曲线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.切线方程 ...
- uva11178 Morley’s Theorem(求三角形的角三分线围成三角形的点)
Morley’s Theorem Input: Standard Input Output: Standard Output Morley’s theorem states that that the ...
- 多个n维向量围成的n维体积的大小
前言 上周我们数学老师给了我们一道题,大意就是两个向量a和b,一个点M=$x*a+y*b$,x,y有范围,然后所有M组成的面积是一个定值,求x+y的最小值.当然这是道小水题,但我在想,如果把两个向量变 ...
- CodeForces 8D Two Friends 判断三个圆相交
题意: 有两个人\(Alan\)和\(Bob\),他们现在都在\(A\)点,现在\(Bob\)想去\(B\)点,\(Alan\)想先到\(C\)点再去\(B\)点. \(Alan\)所走的总路程不能超 ...
- LeetCode 85 | 如何从矩阵当中找到数字围成的最大矩形的面积?
本文始发于个人公众号:TechFlow,原创不易,求个关注 今天是LeetCode专题53篇文章,我们一起来看看LeetCode中的85题,Maximal Rectangle(最大面积矩形). 今天的 ...
- HDU 3467 (求五个圆相交面积) Song of the Siren
还没开始写题解我就已经内牛满面了,从晚饭搞到现在,WA得我都快哭了呢 题意: 在DotA中,你现在1V5,但是你的英雄有一个半径为r的眩晕技能,已知敌方五个英雄的坐标,问能否将该技能投放到一个合适的位 ...
- codeforces 8D Two Friends 二分+ 判断三个圆是否有公共交点
题目链接 有两个人x, y, 现在在A点, x要直接去B点, y要先去C点在去B点, 现在给出x, y两人可以行走的最大距离T1, T2, 求出他们从A点出发之后, 可以走的最长的公共路径. 我们先看 ...
- poj3819 Coverage (求直线与圆的交占直线的百分比 )
题意:给你一条直线和若干个圆,求圆与直线相交的长度占整条直线的比例 解题思路:通过定比分点的方法求出圆与直线的交占圆的比例. 第一步:(确定投影的方向是x轴还是y轴) (1)当直线的line.s(x, ...
随机推荐
- Unity 开发游戏Game分辨率设置
最近自己开发小游戏,突然又被Game视图中设置分辨率被诱惑了, 我到底该怎么设置分辨率设置的图片才能让电脑和手机尺寸显示的大小一模一样呢? 然后又被手机尺寸和分辨率迷惑了! =.= 越搞越混 分辨 ...
- Gradle Tips#1-tasks
原文链接 以这篇博客開始,我将写一系列关于Gradle的文章,用来记录接触Gradle构建脚本以来我所理解的Gradle. 今天要讲的就是Gradle tasks以及task的配置和运行.可能有的读者 ...
- Sprite Kit编程指南(1)-深入Sprite Kit
深入Sprite Kit 学习Sprite Kit最好的方法是在实践中观察它.此示例创建一对场景和各自的动画内容.通过这个例子,你将学习使用Sprite Kit内容的一些基础技术,包括: · ...
- Android内存泄漏监测(MAT)及解决办法
http://ttlnews.blogspot.com/2010/01/attacking-memory-problems-on-android.html 这篇文章是2010年1月份写的,其中有些已经 ...
- [Python][自己写的杀病毒脚本]
电脑里的HTML都插入了一段VB病毒代码..只能自己手动清除了..发现Python确实好用 import os import re; Root = ["H:"]; for root ...
- nopCommerce架构分析系列(二)数据Cache
原文(http://www.cnblogs.com/gusixing/archive/2012/04/12/2443799.html)非常感谢作者顾思行的分享! 序言 在很多访问量较大的系统中,尤其在 ...
- ASP.NET导入Excel到SQL数据库
protected void btnChange_Click(object sender, EventArgs e) { UserInfoClass tClass = (UserInfoClass)S ...
- easyui-combobox绑定json数据
用的C#语言 后台取数据,就不用废话了,先看看序列化json数据 /// <summary> /// 对象转JSON /// </summary> /// <param ...
- C++单链表的创建与操作
链表是一种动态数据结构,他的特点是用一组任意的存储单元(可以是连续的,也可以是不连续的)存放数据元素.链表中每一个元素成为“结点”,每一个结点都是由数据域和指针域组成的,每个结点中的指针域指向下一个结 ...
- (原)Eclipse中将JNI生成的so打包成jar的步骤
说明:新人,对java不熟,见谅. 1. 新建工程,添加好native support,写好对应的文件(包括cpp文件,so文件和对应的java文件,此处称对应的java文件为SoJAR.java,) ...