Tell me the area---hdu1798 (数学 几何)
http://acm.hdu.edu.cn/showproblem.php?pid=1798
给你两个圆求阴影部分的面积
求出两个扇形的面积减去四边形的面积
扇形的面积是度数(弧度制)*半径的平方
不能用PI 3.1415926 要用acos(-1.0);
求四边形面积就是两个三角形 用海伦公式
因为精确度比较高 所以就不能用PI 3.1415926
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <math.h> using namespace std;
#define memset(a,b) memset(a,b,sizeof(a))
#define N 1100000
typedef long long ll;
#define PI 3.1415926 int main()
{
double x1,y1,r1,x2,y2,r2;
while(scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&r1,&x2,&y2,&r2)!=EOF)
{
double rr=min(r1,r2);
double l=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
if(l>=r1+r2)
{
printf("0.000\n");
continue;
}
else if(l<=fabs(r1-r2))
{ printf("%.3lf\n",acos(-1.0)*rr*rr);
continue;
}
double cos1=(r1*r1+l*l-r2*r2)/(2.0*r1*l);
double cos2=(r2*r2+l*l-r1*r1)/(2.0*r2*l); double ss1=r1*acos(cos1)*r1;///r1扇形的面积
double ss2=r2*acos(cos2)*r2;
double p=(r1+r2+l)/2.0;///
double S=*sqrt(p*(p-r1)*(p-r2)*(p-l));///四边形的面积
printf("%.3lf\n",ss1+ss2-S);
}
return ;
}
Tell me the area---hdu1798 (数学 几何)的更多相关文章
- hdu 1115 Lifting the Stone (数学几何)
Lifting the Stone Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- hdu 1577 WisKey的眼神 (数学几何)
WisKey的眼神 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
- ACM: FZU 2110 Star - 数学几何 - 水题
FZU 2110 Star Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Pr ...
- poj 1701【数学几何】
The area Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Su ...
- TZOJ 3244 Happy YuYu's Birthday(数学几何)
描述 9月10日教师节,也是YuYu的生日,妈妈给YuYu准备了一个很大的圆形蛋糕,YuYu看中了蛋糕中间那诱人的樱桃(都挤到一块啦),小家伙很高兴,心里开始盘算着如何将樱桃全部分给自己.YuYu是个 ...
- HDU 1798 Tell me the area (数学)
题目链接 Problem Description There are two circles in the plane (shown in the below picture), there ...
- Gym 101334A Area 51 数学
大致题意: 给出n个建筑的二维坐标,每个建筑名称为一个字母,不同坐标的建筑可以有同一名称,并保证这些坐标都是在y轴上半轴.给出一串建筑名称的字符串,在X轴上找出一个或多个区间,使Nick在这个区间上从 ...
- HDU 4946 Area of Mushroom (几何凸包)
题目链接 题意:给定n个人,每个人有一个速度v方向任意.如果平面中存在一个点只有某个人到达的时间最短(即没有人比这个人到的时间更短或相同),那么我们定义这个店归这个人管辖,现在问这些人中哪些人的管辖范 ...
- gcc【数学几何】
GCC Time Limit: 1000MS Memory limit: 65536K 题目描述 The GNU Compiler Collection (usually shortened to G ...
- LightOj1385 - Kingdom Division(数学几何题)
题目链接:http://lightoj.com/volume_showproblem.php?problem=1385 题意:下图中已知面积 a b c 求 d; 如果d的面积不确定,输出-1. 连接 ...
随机推荐
- 自欺欺人的使用 NSTimer 销毁
自欺欺人的使用 NSTimer 销毁 Demo地址 1.NSTimer是要加到runloop中才会起作用. 常见的创建timer方式 // 第一种方式 @property (nonatomic , s ...
- 登录脚本重构by封装
package com.gubai.selenium; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; imp ...
- Mysql无法启动服务解决办法
只需要输入:mysqld --initialize 进行初始化,即可启动
- 浅谈p值(p-value是什么)
当我们说到p-value时,我们在说什么? “这个变量的p-value小于0.05,所以这个变量很重要” ........ 你真的知道自己在说什么么???这个p-value到底是个什么鬼?为什么小于0 ...
- js 调用flash在chrome报错
1.网页内嵌动态生成的flash出错,出错信息如下: #25081850 myChartId::RendererManager Error >> There was an error re ...
- jqury 延迟方法
$("button").click(function(){ $("#div1").delay("slow").fadeIn(); ...
- 四、StaticList 和 DynamicList
1.StaticList类模板 StaticList的设计要点:类模板 使用原生数组作为顺序存储空间 使用模板参数决定数组大小 template <typename T, int N> c ...
- POJ-2442-Sequence(二叉堆)
POJ-2442 Description Given m sequences, each contains n non-negative integer. Now we may select one ...
- laravel 数据导出
支持:php 7.0 以上 三种方案总结介绍: 第一种:最简单且不会有长久隐患.但不适合数据量多 第二种: 适合中等数据量,不会有长久隐患.但导出时极占内存 第三种:适合大量数据,不会占据 ...
- Http请求封装(对HttpClient类的进一步封装,使之调用更方便。另外,此类管理唯一的HttpClient对象,支持线程池调用,效率更高)
package com.ad.ssp.engine.common; import java.io.IOException; import java.util.ArrayList; import jav ...