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, ...
随机推荐
- qt QSortFilterProxyModel
# -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.Qt import * from PyQt4. ...
- RESTEasy 3.X Helloworld
最近呢,RESTEasy也升级了.升到了3.X. 官网:http://www.jboss.org/resteasy 集成使用也非常简单(相比SOAP而言) 第一步:下载jar包 resteasy是托管 ...
- NYOJ17,单调递增最长子序列
单调递增最长子序列 时间限制:3000 ms | 内存限制:65535 KB 难度:4 描写叙述 求一个字符串的最长递增子序列的长度 如:dabdbf最长递增子序列就是abdf.长度为4 输入 第 ...
- Android——SQLite实现面向对象CRUD
android中SQLite的使用,事实上倒也不难.可是与JDBC操作数据库相比,这个还是有点不顺手,并且我好久没写底层的封装了,使用SSM框架这些都不须要考虑......好了,废话不多说.以下直接建 ...
- [置顶] 【cocos2d-x入门实战】微信飞机大战之十二:分数的本地存储
转载请表明地址:http://blog.csdn.net/jackystudio/article/details/12036237 作为一个单机游戏,连分数存储的的功能都没有,让它怎么在单机游戏圈里混 ...
- linux学习记录 常用指令大全
1.开启关闭服务器(即时生效): service iptasbles start service iptasbles stop 2.在开启了防火墙时,做如下设置,开启相关端口, 修改/etc/sysc ...
- DE2带的IP核ISP12362报错问题解决 Error:avalon_slave_1_irq: associatedAddressablePoint out of range
问题来源与对友晶提供的ISP1362 IP核的使用,由于Quartus II版本问题,它提供的IP基于7.0版本,而我用的版本为11.1,在SOPC Builder中重新加载IP,就出现了上述的错误报 ...
- js中的eval方法转换对象时,为何一定要加上括号?
待转换的是一个Json字符串: {'name':'新欢'} 而使用如下这种方式调用则会抛出语法异常, eval("{'name':'新欢'}"); 必须加上括号才行 eval(&q ...
- Sql语句不能识别Go的解决办法(动态创建表的触发器)
问题来源 用sqlserver直接打开sql文本,执行没问题,但是当用Sqlcommand类执行cmdtext命令文本时总是失败报错. 原因分析及解决 用数据库直接执行sql语句没问题,甚至还可以用G ...
- C#索引器:在集合或数组中取出某一个元素 举例 _【转】
Garmmar: [访问修饰符] 数据类型 this[参数列表] { get { 获取索引器的内容 } set { 设置索引器的内容 } } Eg: <span style="font ...