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 ;
}

最新文章

  1. js url.slice(star,end) url.lastIndexOf(&#39;/&#39;) + 1, -4
  2. 深入理解javascript系列,读书笔记
  3. Oracle添加数据报文字与格式字符串不匹配错误
  4. jboss服务器修改端口说明
  5. 实验 snort安装配置与规则编写
  6. 基于.NET的WebService的实现和WCF的实现
  7. Spark生态系统BDAS
  8. JQuery Ajax 在asp.net中使用小结
  9. PHP reset() 函数
  10. javascript 倒计时代码
  11. jquery ajax 跨域提交(附IE浏览器解决方案)
  12. String的使用
  13. [Go语言学习]之一:搭建单元测试环境
  14. (hdu step 8.1.6)士兵队列训练问题(数据结构,简单模拟——第一次每2个去掉1个,第二次每3个去掉1个.知道队伍中的人数&amp;lt;=3,输出剩下的人 )
  15. MIPS(极路由1s[mt7620a])平台OpenWrt路由器系统内的Go应用程序开发
  16. 【Java】【13】两个double类型比较大小
  17. Largest Rectangle in a Histogram POJ - 2559 (单调栈)
  18. 3.2 unittest执行顺序
  19. stm32的双向io口
  20. Java List &lt;T&gt; T[] toArray(T[] a) implementation

热门文章

  1. How the performance impacts your revenue-性能影响营收
  2. AS400服务程序总结
  3. MongoDB最简单的入门教程之一 环境搭建
  4. pylint安装失败的解决方法
  5. laravel homestead comoser install 报错
  6. C ++ _多线程笔记
  7. 暑假集训 || 树DP
  8. PHP01 LAMP网站构建
  9. sql中group by
  10. 用户管理命令--passwd,usermod,userdel