描述

There are two circles on the plane. Now you must to calculate the area which they cover the plane. For example, in Figure 1, the area of the red region is the answer of this problem.

输入

The input contains multiple test cases. The first line contains an integer T describing the number of test cases. Each case contains two lines. One line describes one circle. For each line has three integers x, y, r, indicating the coordinate of the centre and radius. All the numbers are separated by spaces. All the input integers are within the range of [-1000, 1000].

输出

For each test case, output one line containing a number with 3 digits after decimal point representing the answer describing above.

样例输入

2
2 2 2
1 4 3
2 2 1
-2 -2 1

样例输出

32.462
6.283

只能说是高中数学知识,模拟一下就完了。但是我好像把学得还回去了,结果想了好久好久。。。。。。

#include<stdio.h>
#include<math.h>
double min(double a,double b)
{if(a>b) a=b;return a;
}
double max(double a,double b)
{if(a<b) a=b;return a;
}
int main()
{double x1,x2,y1,y2,r1,r2,S;int n;scanf("%d",&n);while(n--){scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&r1,&x2,&y2,&r2);double d=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));double s1=acos(-1)*r1*r1;double s2=acos(-1)*r2*r2;if(d>=r1+r2) S=s1+s2;else if(d<=max(r1,r2)-min(r1,r2)) S=max(s1,s2);else{double A=2*acos((r1*r1+d*d-r2*r2)/(2*r1*d));double shan1=A*r1*r1/2;double sanjiao1=sin(A)*r1*r1/2;double B=2*acos((r2*r2+d*d-r1*r1)/(2*r2*d));double shan2=B*r2*r2/2;double sanjiao2=sin(B)*r2*r2/2;S=s1+s2-(shan1+shan2-sanjiao1-sanjiao2);}printf("%.3lf\n",S);}
}

转载于:https://www.cnblogs.com/mayouyou/p/9030693.html

Area of Circles II(数论)相关推荐

  1. 洛谷P1414 又是毕业季II 数论

    洛谷P1414 又是毕业季II 数论 d[ i ] 表示这些数中有几个数有因数 i 对于输入的每个数 都sqrt(val) 记录下 然后问你 n个数的最大公约数是多少, 相当于是问你 有 n 个数 有 ...

  2. P1414 又是毕业季II(数论)

    又是毕业季II - 洛谷https://www.luogu.com.cn/problem/P1414 #include <iostream> #include <cstdio> ...

  3. Area of a circle

    In geometry, the area enclosed by a circle of radius r is πr2. Here the Greek letter π represents th ...

  4. 杭电oj题目题型分类(转)

    1001 整数求和 水题 1002 C语言实验题--两个数比较 水题 1003 1.2.3.4.5... 简单题 1004 渊子赛马 排序+贪心的方法归并 1005 Hero In Maze 广度搜索 ...

  5. HDOJ题目分类大全

    版权声明:本文为博主原创文章,欢迎转载,转载请注明本文链接! https://blog.csdn.net/qq_38238041/article/details/78178043 杭电里面有很多题目, ...

  6. HDU题目分类大全【大集合】

    基础题: 1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028.1029.  1032.1037.1040.1048.1056.105 ...

  7. 杭电OJ题目分类(转载)

    1001 整数求和 水题 1002 C语言实验题--两个数比较 水题 1003 1.2.3.4.5... 简单题 1004 渊子赛马 排序+贪心的方法归并 1005 Hero In Maze 广度搜索 ...

  8. hdoj杭电问题分类

    杭电上的题虽然多,但是一直苦于找不到问题分类,网页都是英文的,所以平时做题也没怎么看,今天仔细一看,问题分类竟然就在主页....做了那么久的题居然没发现,表示已经狗带..不要笑,不知道有没有像我一样傻 ...

  9. 转载:Hdu 题目分类

    原址点击 基础题:1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028.1029. 1032.1037.1040.1048.1056. ...

最新文章

  1. Solaris 上swap -s的解释
  2. R语言包在linux上的安装等知识
  3. c#文本框只能填入数字和字母
  4. 根据数据库表gengxin实体类_ASP.NET开发实战——(十二)数据库之EF Migrations
  5. Java版本的Bot Framework SDK
  6. .NET Core微服务之路:让我们对上一个Demo通讯进行修改,完成RPC通讯
  7. js setTimeout 使用方法
  8. javascript设计模式_JavaScript 设计模式 学习总结
  9. 格力又有新专利了:“一种铁芯冲片、电机及新能源汽车”
  10. Hibernate的Cascade——级联操作
  11. spring aop和事务同时开启带来的一些问题
  12. 使用python抓取天涯帖子,并实现“只看楼主”功能
  13. 走进波分 -- 16.Optix OSN9800产品介绍
  14. PicoNeo开发中遇到的问题(一)
  15. 关于RGV下料的智能动态调度
  16. 微信小程序文本如何换行
  17. 由设计稿一键智能生成代码的快捷软件
  18. VBA—压缩文件夹成一个rar压缩包
  19. matlab将多项式通分,matlab多项式因式分解
  20. SpringCloud微服务注册和消费模式总结

热门文章

  1. 关于orm传递ctx的一点理解
  2. Rem布局的原理解析
  3. [Python] 函数lambda(), filter(), map(), reduce()
  4. 设计模式---创建型模式
  5. python设计模式19-观察者模式
  6. Onvif之框架生成-基于gsoap2.8.27
  7. Laravel核心解读--控制器 1
  8. kafka控制台模拟消费_Flink初试——对接Kafka
  9. Spring Boot加入websocket后,单元测试报错(javax.websocket.server.ServerContainer not available)
  10. springboot实现快速整合mybatis+mysql