Problem Description
Edward is a worker for Aluminum Cyclic Machinery. His work is operating mechanical arms to cut out designed models. Here is a brief introduction of his work.
Assume the operating plane as a two-dimensional coordinate system. At first, there is a disc with center coordinates (0,0) and radius R. Then, m mechanical arms will cut and erase everything within its area of influence simultaneously, the i-th area of which is a circle with center coordinates (xi,yi) and radius ri (i=1,2,⋯,m). In order to obtain considerable models, it is guaranteed that every two cutting areas have no intersection and no cutting area contains the whole disc.
Your task is to determine the perimeter of the remaining area of the disc excluding internal perimeter.
Here is an illustration of the sample, in which the red curve is counted but the green curve is not.
 
Input
The first line contains one integer T, indicating the number of test cases.
The following lines describe all the test cases. For each test case:
The first line contains two integers m and R.
The i-th line of the following m lines contains three integers xi,yi and ri, indicating a cutting area.
1≤T≤1000, 1≤m≤100, −1000≤xi,yi≤1000, 1≤R,ri≤1000 (i=1,2,⋯,m).
 
Output
For each test case, print the perimeter of the remaining area in one line. Your answer is considered correct if its absolute or relative error does not exceed 10−6.
Formally, let your answer be a and the jury's answer be b. Your answer is considered correct if |a−b|max(1,|b|)≤10−6.
 
Sample Input
1
4 10
6 3 5
10 -4 3
-2 -4 4
0 9 1
 
Sample Output
81.62198908430238475376
 
Source
 
Recommend
chendu   |   We have carefully selected several similar problems for you:  6361 6360 6359 6358 6357 
 
 
 
 #include <bits/stdc++.h>
using namespace std;
#define N 120
#define pi acos(-1.0)
struct point{
double x,y;
};
struct circle{
point po;
double r;
}cir[N];
double dist (point a,point b){
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
int t,m;
double R;
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%d%lf",&m,&R);
circle a;
a.po.x=;a.po.y=;
a.r=R;
for(int i=;i<m;i++)
{
scanf("%lf%lf%lf",&cir[i].po.x,&cir[i].po.y,&cir[i].r);
}
double ans=*pi*R;
for(int i=;i<m;i++)
{
double dis=dist(a.po,cir[i].po);
if(dis-cir[i].r<a.r&&dis+cir[i].r>=a.r){
double d1=*acos((dis*dis+a.r*a.r-cir[i].r*cir[i].r)/(*dis*a.r));
double d2=*acos((dis*dis+cir[i].r*cir[i].r-a.r*a.r)/(*dis*cir[i].r));
double l1=d1*a.r;
double l2=d2*cir[i].r;
ans-=l1;
ans+=l2;
}
}
printf("%.10f\n",ans);
} return ;
}
/*
//判段两个圆的位置关系:
相离 : dis(a,b)>a.r+b.r
外切 : dis(a.b)==a.r+b.r
相交 : dis(a,b)-min(a.r,b.r)<max(a.r,b.r)&&dis(a,b)+min(a.r,b.r)>max(a.r,b.r)
内切 : dis(a,b)+min(a.r,b.r)==max(a.r,b.r)
内含 : dis(a,b)+min(a,r)<max(a.r,b.r)
*/
 

hdu 6354的更多相关文章

  1. HDU 6354.Everything Has Changed-简单的计算几何、相交相切圆弧的周长 (2018 Multi-University Training Contest 5 1005)

    6354.Everything Has Changed 就是计算圆弧的周长,总周长=大圆周长+相交(相切)部分的小圆的弧长-覆盖掉的大圆的弧长. 相交部分小圆的弧长直接求出来对应的角就可以,余弦公式, ...

  2. HDU 6354 Everything Has Changed(余弦定理)多校题解

    题意:源点处有个圆,然后给你m个圆(保证互不相交.内含),如果源点圆和这些原相交了,就剪掉相交的部分,问你最后周长(最外面那部分的长度). 思路:分类讨论,只有内切和相交会变化周长,然后乱搞就行了.题 ...

  3. HDU 6351暴力枚举 6354计算几何

    Beautiful Now Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)T ...

  4. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  5. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  6. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  7. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  8. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

  9. HDU 1796How many integers can you find(容斥原理)

    How many integers can you find Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d ...

随机推荐

  1. python之三级菜单

    python之三级菜单 要求: 1. 运行程序输出第一级菜单 2. 选择一级菜单某项,输出二级菜单,同理输出三级菜单 3. 菜单数据保存在文件中 4. 让用户选择是否要退出 5. 有返回上一级菜单的功 ...

  2. code review的意义

    https://blog.csdn.net/brodycai/article/details/19636621

  3. css3的animation动画

    animation 设置对象的动画特效   有6个主要的值 animation-name   动画名称 animation-duration   动画持续时间 animation-timing-fun ...

  4. hard link && symbolic link

    hard link :硬连接,多了一个inode,指向原始的inode,通过这个硬连接删除文件,文件不会被真正删除,而是删除这个inode symolic link:符号连接相当于快捷方式

  5. angularjs实现导航菜单切换高亮

    <ul> <li ng-repeat="(index, item) in headerList"> <a ui-sref="{{item.h ...

  6. js中.toString()和String()的一丢丢区别

    1..toString()可以将所有的的数据都转换为字符串,但是要排除null 和 undefined 例如将false转为字符串类型 <script>   var str = false ...

  7. Android 设置资源字体,屏幕截图

    字体设置 将下载的资源字体放在assets中, 引用设置 edit..setTypeface(Typeface.createFromAsset(getAssets(), "字体名.ttf&q ...

  8. ionic 2 起航(一)

    最近的工作项目开始接触Ionic2.学习了一段时间,现在跟大家分享一下. 什么是Ionic 2?     百度一下,ionic是一个用来开发混合手机应用的,开源的,免费的代码库.可以优化html.cs ...

  9. MySQL memory引擎 table is full 问题处理

    解决mysql的内存表“table is full”错误   101209 13:13:32 [ERROR] /usr/local/mysql/bin/mysqld: The table ‘test_ ...

  10. 【Troubleshooting Case】Exchange Server 组件状态应用排错?

    在Exchange 2013中,引入了“服务器组件状态”的概念.服务器组件状态从运行环境的角度提供对组成Exchange Server的组件的状态的精细控制. 日常排错时,常常会把Exchange 服 ...